| Summary: | /bin/sh builtins redirection failures abort entire script | ||
|---|---|---|---|
| Product: | Base System | Reporter: | jonny <jonny> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.6-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed Contrary to popular belief, bash does not define the standard to unix shells... :) This behavior is consistant with the expected historical behavior of /bin/sh; csh and tcsh also behaves in a similar manner. If you want to ignore failures hen redirecting, you can put parenthesis around the command, like: (echo foo > /nonexistant/foo/bar) |
See example below How-To-Repeat: This script fails with /bin/sh, works with bash #! /bin/sh TestFunc() { ${ECHO} "no perm" > $file # Builtin echo does not reach here ${ECHO} ok ${ECHO} "no perm" >> $file ${ECHO} ok } file=/tmp/xxx touch $file chmod 000 $file ECHO=/bin/echo TestFunc ECHO=echo TestFunc