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 the shell to exit due to the grep condition then I recommend coding it explicitly. if grep foo file; then echo "foo found" exit 1 fi if ! grep foo file; then echo "foo not found" exit 1 fi grep foo file && { echo "foo found"; exit 1 ;} grep foo file || { echo "foo found"; exit 1 ;} All are better style (yes, I know it is a matter of taste) than trying to use 'set -e' as a catch-all. Because 'set -e' is what it is and is what it has been for decades. That ship sailed years ago. Bob