Front page | perl.dbi.dev |
Postings from February 2012
Re: DBD::Oracle
Thread Previous
|
Thread Next
From:
Aaron Crane
Date:
February 11, 2012 14:29
Subject:
Re: DBD::Oracle
Message ID:
CACmk_tsXYucn5D4fGxhGW_5vrTUpERUtLM3BaxM9twDfRiroug@mail.gmail.com
Yanick Champoux <yanick.champoux@gmail.com> wrote:
> 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
>
> --make a difference...
Ah, I can explain what's going on there. If you give Perl `system` a
single argument, it looks at the contents of that string, and decides
whether it's a "trivial" command. Trivial commands in this sense are,
roughly, those that contain no awkward punctuation characters — which
would imply that the command needs to be executed by a shell. If Perl
thinks no shell is needed, it optimises by executing the command
directly, saving a shell process. Otherwise, it passes the command to
the appropriate shell as desired.
In this case, if you do `system "exit 1;"`, the semicolon forces
`system` to pass the command to a shell, and everything works as
expected. On the other hand, `system "exit 1"` with no semicolon is
executed directly. But there's no command named `exit` — it's a shell
builtin (and has to be). So `system` is giving you the behaviour you
get in the "command not found" case, namely a negative return value.
--
Aaron Crane ** http://aaroncrane.co.uk/
Thread Previous
|
Thread Next