G'day ikegami,
On Mon Jul 14 22:53:40 2008, ikegami wrote:
Show quoted text> According to your documentation, "system($cmd, @args);" executes the
> command while "avoiding the shell", but that's not always true.
You're quite right here. IPC::System::Simple tries to use similar
semantics to Perl's built-in system(). Unfortunately, it's so similar
it also duplicates some of the bugs. Both suffer the identical problem
with:
system($cmd, @args);
calling the shell when @args is an empty list. The built-in provides an
ugly way around this by having the "exotic" form of system, but that's
not an option to me, since the exotic form of system can't be prototyped.
There are a few work-arounds that sometimes get seen, notably by
appending the empty string or "--" to the argument list (depending upon
the command and the OS). However they're clunky, ugly, and not
"simple", which is what this module is all about.
Show quoted text> I don't consider this just a documentation bug. The module is useless to
> me if it doesn't provides a means of avoiding the shell (both for
> capturing and not).
I can create an interface into IPC::System::Simple for system/capture
that never invokes the shell. The hard part here is determining the
name for such an interface. The following are verbose and obvious, but
I think are too ugly:
noshell_system(...);
noshell_capture(...);
I'm tempted by:
systemx(...);
capturex(...);
or:
xsystem(...);
xcapture(...);
because they're only a single keystroke different, they still read
nicely, and the the 'x' fits nicely into my brain as being short for
"exclude the shell".
Suggestions for better names highly appreciated, especially since I'd
like to implement said interface by OSCON (next week).
Another option is extending the interface a little by allowing special
symbols in the list of exit values, eg:
system( [ NO_SHELL ], $cmd, @args);
However this feels very inelegant, and not at all simple.
Of course, what I'd *really* like is for the code to actually Do What I
Mean when one writes:
system($cmd, @args);
capture($cmd, @args);
That's a hard problem, because once we're inside system/capture, I don't
know of any way that allows me to tell if @args was absent, or merely
empty, especially if I want to retain backwards compatibility with
5.6.0. I don't consider using source filters to achieve this to be a
good idea.
Further thoughts, suggestions, feedback, and patches[1] are all very
welcome.
Many thanks,
Paul
[1]
http://github.com/pfenwick/ipc-system-simple/tree/master is the
source repository for the module.