Amoe has asked for the wisdom of the Perl Monks concerning the following question:
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.)
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Shell.pm mangling arguments with embedded whitespace?
by PodMaster (Abbot) on Jun 15, 2003 at 05:51 UTC |