7 Aug 2009 15:18
Feature request: set -o pipefail
Peter Jakobi <jakobi <at> acm.org>
2009-08-07 13:18:33 GMT
2009-08-07 13:18:33 GMT
Hi, [Note: I'm not on the list, so put jakobi <at> acm.org in cc: if I need to reply. thanx, Peter] Feature request: implement set -o pipefail. This will allow the user to request the return code to be the one of the first pipe command with a non-zero error. The lack of which can be quite painful in scripting, even if a bourne-shell/posix subset would otherwise be quite sufficient. Advantages: This allows use of pipes with proper error detection, which is quite helpful for init scripts / cron or generally administration-style scripts which exec shell commands from shell/perl/python/... scripts. Usage case: have a command like mv -i act on user input, while keeping output (stdout+err) in a log AND returning mv's error code (or tee's if mv is ok). in a perl script, this would be something like: system "set -o pipefail; mv -i foo bar </dev/tty 2>&1 | tee -a LOG"; Part of the problem is that the shell used for open/system is often hard-coded in the interpreter to be /bin/sh.(Continue reading)
RSS Feed