Ludovic Courtès wrote:

> Eelco Dolstra <[EMAIL PROTECTED]>
> writes:
> 
>> BTW, this isn't the only place where bash silently ignores errors (even with
>> "-e" active).  For instance, errors from subshells (e.g. "(cd /foo)") are 
>> ignored.
> 
> Really?
> 
>   $ ( cd /foo ) ; echo $?
>   bash: cd: /foo: No such file or directory
>   1

I meant that the calling shell ignores the exitcode of the subshell when -e is
active.  So an error in

  (cd $somedir && tar cf $out/foo.tar bla)

is ignored, while it isn't if you do

  cd $somedir && tar cf $out/foo.tar bla

But this changes the current directory, which is why you want a subshell.  The
workaround is to say

  (cd $somedir && tar cf $out/foo.tar bla) || false

Stricly speaking this isn't a bug, because the bash man-page says that "-e" only
applies to "simple commands" (not subshells).  But it's still counter-intuitive
IMHO.

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/
_______________________________________________
nix-dev mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/nix-dev

Reply via email to