This is the mail archive of the
cygwin-apps@cygwin.com
mailing list for the Cygwin project.
Re: gbs cleanup patch, 2nd try
- From: Andrew Schulman <andrex at alumni dot utexas dot net>
- To: cygwin-apps at cygwin dot com
- Date: Sat, 30 Oct 2004 03:36:46 -0400
- Subject: Re: gbs cleanup patch, 2nd try
>> Great. Have you tested whether the -e flag gets propagated inside the
>> functions?
>
> Yes, I have now:
>
> $ /bin/sh -e ; echo "finished /bin/sh -e, status=$?"
> $ echo $-
> eims
> $ # the -e flag propagates into subshells:
> $ tst1() { echo $- ; }
> $ tst1
> eims
> $ # false result inside a function causes subshell and
> $ # main shell to immediately exit:
> $ tst2() { false ; echo "continuing execution" ; }
> $ tst2
> finished /bin/sh -e, status=1
Sorry, the above is wrong:
$ /bin/sh -e ; echo "finished /bin/sh -e, status=$?"
$ ( echo $- )
ehimBH
$ ( false ; echo "continuing execution" )
$ echo $?
1
So -e is effective in the subshell, but when it returns its false status it
doesn't cause its parent shell to exit. I now see in the manual that this is
because a subshell isn't a "simple command".
So I will have to rethink how best to handle a false return status of a
subshell.