This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]