Tongue-in-cheek answers: Because having another module to do "system" doesn't actually make things simpler?

There's no denying that IPC::System::Simple is yet another wheel. It overlaps with a lot of the existing modules that handle calls to external commands. However it exists specifically to present the smallest possible learning curve for someone who wants to Do The Right Thing when calling external commands, but doesn't care how.

I can take someone who has almost no understanding of how Perl works, who has a full bladder, and a flight to catch in five minutes, and still teach them how to use IPC::System::Simple. I can do it in one slide in a classroom.

When I can tell people they can take their ugly, legacy Perl code, and replace each instance of system() with run() and suddenly get error checking and detailed diagnostics for free, that's a powerful force. If they want anything more than that, that's what all the other modules are for.

Because having yet another special case of how things work on Windows doesn't make things simpler?

I agree entirely! This is specifically making the module work the same way under Windows as it does everywhere else. Let's take your example:

For example, you suggest that a multi-arg list never be passed to the shell. So how would you replace/handle this call to "system":

system("echo", "%PATH%"); # works fine on Win32

And here's the crux of the problem. Currently, that does work fine under Windows. According to the documention in perldoc -f exec, it shouldn't:

Using an indirect object with "exec" or "system" is also more secure. This usage (which also works fine with system()) forces interpretation of the arguments as a multivalued list, even if the list had just one argu- ment. That way you're safe from the shell expanding wildcards or splitting up words with whitespace in them.

@args = ( "echo surprise" ); exec @args; # subject to shell escapes # if @args == 1 exec { $args[0] } @args; # safe even with one-arg list

Under Windows, Perl's system() is currently doing exactly what it shouldn't do, interpreting shell metacharacters and commands when called with multiple arguments. In my opinion, this is a bug in Perl.

So, I guess my real question should be this. At what point does IPC::System::Simple break bug-for-bug compatibily with Perl, and do what Perl says it should do, rather than what Perl actually does?


In reply to Re^2: RFC: IPC::System::Simple under Win32 by pjf
in thread RFC: IPC::System::Simple under Win32 by pjf

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.