So in my endless quest for syntactic sugar, I discovered the standard Shell.pm module. This will make my random glue much more readable, thought I. So I tried it out, and it was good; even better when combined with autoquoting arrows (not demonstrated here for clarity). Trouble is, try as I might, I was unable to pass arguments with spaces to the spawned process: they were always seen as two separate arguments, no matter how much I escaped them.

use Shell qw(oggenc); # ("bar.wav" doesn't exist, so errors of the form "cannot open input f +ile # 'bar.wav' indicate the command is being parsed correctly. "Multiple + input # files" type errors indicate that the spaced argument is being seen a +s two.) # All the system() calls work... # ERROR: Cannot open input file "bar.wav": No such file or directory system("oggenc -o foo.ogg -c " . quotemeta("composer=J. Random Hacker" +) . " bar.wav"); # ERROR: Cannot open input file "bar.wav": No such file or directory system("oggenc", "-o", "foo.ogg", "-c", "composer=J. Random Hacker", " +bar.wav"); # None of the Shell.pm ones do. # ERROR: Multiple input files with specified output filename: suggest +using -n oggenc("-o", "foo.ogg", "-c", "composer=J. Random Hacker", "bar.wav"); # ERROR: Multiple input files with specified output filename: suggest +using -n oggenc("-o", "foo.ogg", "-c", quotemeta("composer=J. Random Hacker"), +"bar.wav"); # ERROR: Multiple input files with specified output filename: suggest +using -n oggenc("-o foo.ogg -c " . quotemeta("composer=J. Random Hacker") . " b +ar.wav");

Does anyone know how I can pass an argument with whitespace in it? If not, why, and is this to be construed as a bug or a feature? Thanks in advance. (Looking back, I have no idea why the first part of this node is written in the past tense. Nevermind.)

--
amoe

In reply to Shell.pm mangling arguments with embedded whitespace? by Amoe

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.