Re: failed grep should cause subshell to exit

2013-08-26 Thread Bob Proulx
David Lehmann wrote: > > Subject: Re: failed grep should cause subshell to exit > > set -ex Insert much previous discussion, search the archives, about why set -e is really a terrible paradigm for the shell. Here is a reference. http://mywiki.wooledge.org/BashFAQ/105 If you want

Re: failed grep should cause subshell to exit

2013-08-26 Thread Chris Down
On 2013-08-27 03:48, Chris Down wrote: > It does -- like Andreas said, it just makes it immune to `set -e'. > > $ set -e > $ > file > $ ! grep foo file > $ echo $? > 0 Or, perhaps more closely matching your case: $ set -e $ echo foo > file $ ! grep foo file fo

Re: failed grep should cause subshell to exit

2013-08-26 Thread Chris Down
On 2013-08-26 21:41, David Lehmann wrote: > I expected the '!' to reverse the exit code, such that if the grep return 0 > (success), the expression would return 1 (failure); if the grep returned > non-zero (failure), the expression would return 0 (success). i.e. I > expected the '!' to behave lik

Re: failed grep should cause subshell to exit

2013-08-26 Thread David Lehmann
Andreas, I expected the '!' to reverse the exit code, such that if the grep return 0 (success), the expression would return 1 (failure); if the grep returned non-zero (failure), the expression would return 0 (success). i.e. I expected the '!' to behave like it does in C. -David On Mon, Aug

Re: failed grep should cause subshell to exit

2013-08-19 Thread Andreas Schwab
David Lehmann writes: > ! grep hello x ! causes the shell to ignore -e. Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."

failed grep should cause subshell to exit

2013-08-18 Thread David Lehmann
### should never see done ** ** % uname -a Linux x 2.6.32-279.2.1.el6.x86_64 #1 SMP Thu Jul 5 21:08:58 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux % bash --version GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) ( set -ex ** ** echo hello >x grep hello x