Re: DBD::Oracle

Aaron Crane <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <CACmk_tsXYucn5D4fGxhGW_5vrTUpERUtLM3BaxM9twDfRiroug@mail.gmail.com>
Yanick Champoux <[email protected]> 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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.