Interrupting display of command-line help text

Started by stan, August 09, 2024, 10:56:49 PM

Previous topic - Next topic

FrankB

Quote from: stan on October 20, 2024, 11:40:12 PMFrom what I've read it seems to me this isn't really a surprise since the real cause seems to be a possible bug in Perl itself (and not a bitness mismatch as I thought initially).
Seems logical, and the thought had crossed my mind. But it was bed time by then.

Quote from: obetz on October 21, 2024, 12:49:14 AMFixing the problem in Perl itself seems to be the cleanest way, but might take a while.

We could also consider using a tiny wrapper around "more" to catch the negative return value (errorlevel).

Agree. If I can be of help let me know.

Phil Harvey

Thanks all.  I'll try wrapping the system "more" call in an eval to see if that helps.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

FrankB


Phil Harvey

I've tested this on my Windows 7 virtual machine and it seems to work.  Replace the last line of code in exiftool.pl with these lines:

    # trap warnings and run in eval to avoid Perl bug which gives "Can't spawn" warning on ^C
    local $SIG{'__WARN__'} = sub { $evalWarning = $_[0] };
    eval { system(qq{more < "$docFile"}) };

I'm sorry I was so slow about this -- I was thinking it would require a change to the launcher, and didn't realize I could patch it in ExifTool so easily.

- Phil

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

FrankB

I can confirm that this works on Windows 11. Both in Terminal and Conhost.

Side note: if you leave out the < in
eval { system(qq{more < "$docFile"}) }; (So it is the first parm)

More shows the percentage. (Maybe only on Windows!)
      GPS            r/w/c  |  AFCP           r/w  |  Picture Info   r
      IPTC           r/w/c  |  Kodak Meta     r/w  |  Adobe APP14    r
      XMP            r/w/c  |  FotoStation    r/w  |  MPF            r
      MakerNotes     r/w/c  |  PhotoMechanic  r/w  |  Stim           r
-- More (4%) --

Frank

Phil Harvey

Thanks Frank.

The percent would be useful, but I'll leave it with the "<" to be safe.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

stan

Quote from: Phil Harvey on October 21, 2024, 08:11:10 AMI've tested this on my Windows 7 virtual machine and it seems to work.  Replace the last line of code in exiftool.pl with these lines:
Works quite nicely in Win10 too (naturally)! However, I suggest a slight modification to reintroduce the error message in case windows_exiftool.txt is somehow missing:

    # !PLEASE WRITE THE ACTUAL IF CONDITION PERL CODE BELOW!

    if($docFile does not exist) {
        print "Error opening doc file $docFile\n";    # similar to earlier "Error opening arg file $argFile\n"
    } else {
        # trap warnings and run in eval to avoid Perl bug which gives "Can't spawn" warning on ^C
        local $SIG{'__WARN__'} = sub { $evalWarning = $_[o] };
        eval { system(qq{more "$docFile"}) };
    }

Quote from: Phil Harvey on October 21, 2024, 09:57:33 AMThe percent would be useful, but I'll leave it with the "<" to be safe.
The description of Perl's system() states that if there are no shell metacharacters (such as the redirection operator '<') in the argument, then it is split into words and passed directly to execvp() which is more efficient. So if it doesn't break anything then I agree with Frank that the percentage display thanks to leaving out '<' would be quite useful, and as a bonus possibly more efficient too.

Phil Harvey

Hi Stan,

These are reasonable suggestions.  I will look into implementing them after the planned 13.00 production release.  For 13.00 I am only including bug fixes.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

stan

Thanks Phil; makes no difference to me whether the above code makes its way into ExifTool 13.00 or 13.01. :) Thanks to Frank and Oliver for their valuable inputs too.