in reply to IPC::System::Simple: Why isn't my exception caught?

It's the pipe. The exit value of something you pass to a shell, if it's a piped sequence, is the exit value of the last command:
$ cat nosuchfile | wc -l cat: nosuchfile: No such file or directory $ echo $? 0 $ cat nosuchfile cat: nosuchfile: No such file or directory $ echo $? 1
Some unix shells have workarounds for this, like the PIPESTATUS environment variable, or "set -o pipefail" in bash. Also, IPC::Run provides a built-in mechanism to pipe shell commands together and get the return value of all of them. Personally, I just avoid spawning shell commands with pipes, since it's usually the output of the first command that's interesting, and the function of the second command is almost always easily done within perl (sort, grep, tail, wc, etc).

Replies are listed 'Best First'.
Re^2: IPC::System::Simple: Why isn't my exception caught?
by karlgoethebier (Abbot) on Nov 20, 2013 at 14:48 UTC