My reading of 'perldoc -f system', 'perldoc -f exec', 'perldoc perlport' (system, exec, and wait sections), and 'perldoc perlvar' ($? section) lead me to expect a '-1' error code from system when the program to launch is not found (fails to launch).

The following returns -1 on Unix,

DB<5> x (system 'jxdDoesNotExist'), $?, $! Can't exec "jxdDoesNotExist": No such file or directory at 0 '-1' 1 '-1' 2 'No such file or directory'
As does this:
DB<7> x (system {'jxdDoesNotExist'} 'jxdDoesNotExist'), $?, $! Can't exec "jxdDoesNotExist": No such file or directory at 0 '-1' 1 '-1' 2 'No such file or directory'
But on Windows...
DB<3> x (system {'jxdDoesNotExist'} 'jxdDoesNotExist'), $?, $!, $^E 0 65280 1 65280 2 'No such file or directory' 3 'The system cannot find the file specified' DB<4> x (system 'jxdDoesNotExist'), $?, $!, $^E 'jxdDoesNotExist' is not recognized as an internal or external command +, operable program or batch file. 0 256 1 256 2 'No such file or directory' 3 'Access is denied'
The second Windows 'system' call makes some sense (the error code is from cmd.exe), based on the following snippet from 'perldoc -f system':
            ... On Windows, only the "system PROGRAM
            LIST" syntax will reliably avoid using the shell; "system LIST",
            even with more than one element, will fall back to the shell if
            the first spawn fails.
and from 'perlport'
    exec    "exec LIST" without the use of indirect object syntax ("exec
            PROGRAM LIST") may fall back to trying the shell if the first
            spawn() fails. (Win32)
combined with this snippet from 'perldoc -f system':
            Like "exec", "system" allows you to lie to a program about its
            name if you use the "system PROGRAM LIST" syntax. Again, see
            "exec".
But the 65280 code from the Windows "system PROGRAM LIST" syntax perplexes me. If perl knows the command failed to launch, shouldn't system return '-1' (as documented!!!) ?

See also rt://46333 and rt://95308, which led me to this question


In reply to Why doesn't 'system' return '-1' when a program fails to start on Windows? by jkahrman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.