On Fri, Feb 10, 2012 at 04:29:07PM +0100, H.Merijn Brand wrote:
> On Fri, 10 Feb 2012 10:22:20 -0500, Yanick Champoux
> <yanick.champ...@gmail.com> wrote:
> 
> > On 02/10/12 09:56, Yanick Champoux wrote:
> > >       which should be okay, but I'm suddenly thinking: on some shells
> > > 'exit' might not do what we would expect. Indeed, I just tried:
> > >
> > > $ perl -E'say system "exit 1"'
> > > -1
> > 
> >      And just to keep things interesting, I've noticed that I forgot the 
> > ending semi-colon that is in the test. But surely that won't--
> > 
> > $ perl -E'say system "exit 1"; say system "exit 1;"'
> > -1
> > 256
> 
> % perl -E'say system "exit 1"; say system "exit 1;"'
> -1
> 256
> 
> >      --make a difference...  Uuuh, okay, I need to brush up my shell 
> > syntax skills.  And should probably look into making that test slightly 
> > less shell-dependent.

perldoc -f system says

    If there is only one scalar argument, the argument is checked for
    shell metacharacters, and if there are any, the entire argument is
    passed to the system’s command shell for parsing (this is "/bin/sh -c"
    on Unix platforms, but varies on other platforms).  If there are no
    shell metacharacters in the argument, it is split into words and passed
    directly to "execvp", which is more efficient.

Note that it's always /bin/sh on unix systems (it does't use SHELL env var).

Tim.

Reply via email to