set -e is not clearly documented

2013-10-07 Thread Bartłomiej Palmowski
Hi, lets consider the following: $ echo $BASH_VERSION 4.1.2(1)-release $ cat /etc/system-release Red Hat Enterprise Linux Server release 6.3 (Santiago) $ ( set -e; echo foo; false; echo bar; ) # this one is expected foo $ ( set -e; echo foo; false; echo bar; ) || true # this one is not expected f

Re: Command substitution and exiting from deeply nested subshells

2013-10-07 Thread Greg Wooledge
On Sun, Oct 06, 2013 at 09:37:00PM -0300, Carlos Pita wrote: > I'm not completely sure whether this is a bug or not but it seems > not possible to immediately exit a shell when an error happens at 2+ > levels of subshell nesting. Exiting in a subshell will never cause the parent shell to exit, r

Re: set -e is not clearly documented

2013-10-07 Thread Greg Wooledge
On Mon, Oct 07, 2013 at 11:01:11AM +0200, Bart?omiej Palmowski wrote: > $ ( set -e; echo foo; false; echo bar; ) # this one is expected > foo > $ ( set -e; echo foo; false; echo bar; ) || true # this one is not expected > foo > bar set -e is useless rubbish that should be avoided. See http://mywik

Re: Command substitution and exiting from deeply nested subshells

2013-10-07 Thread Chet Ramey
On 10/6/13 8:37 PM, Carlos Pita wrote: > I'm not completely sure whether this is a bug or not but it seems > not possible to immediately exit a shell when an error happens at 2+ > levels of subshell nesting. Specifically, there is a command at the > top-level shell waiting for the results of a

Re: set -e is not clearly documented

2013-10-07 Thread Chet Ramey
On 10/7/13 5:01 AM, Bartłomiej Palmowski wrote: > Hi, > > lets consider the following: > > $ echo $BASH_VERSION > 4.1.2(1)-release > $ cat /etc/system-release > Red Hat Enterprise Linux Server release 6.3 (Santiago) > $ ( set -e; echo foo; false; echo bar; ) # this one is expected > foo > $ ( set

Re: Command substitution and exiting from deeply nested subshells

2013-10-07 Thread Carlos Pita
> $(xxx) is a word expansion, not a command. Bash will only pay attention to > the exit status of command substitution in one case (x=$(foo)). This > command substitution doesn't contribute to any other command's exit status, > especially `echo', and `set -e' doesn't cause the shell to pay attent

Re: Command substitution and exiting from deeply nested subshells

2013-10-07 Thread Greg Wooledge
On Mon, Oct 07, 2013 at 11:58:48AM -0300, Carlos Pita wrote: > > Exiting in a subshell will never cause the parent shell to exit, > > regardless of depth. > > This is not true in general. > set -e; (exit 1); echo "I don't exist" In this case, it is the "set -e" which may or may not cause the pare