On Fri, 06 Nov 2015, Andreas Henriksson wrote:
> Hi again.
>
> On Fri, Nov 06, 2015 at 03:01:08PM +0100, Peter Palfrader wrote:
> [...]
> > But it should work.
> >
> > An "exit 0" at the end, or a "if [ -d ... ]; then rmdir .. ; fi" would
> > also work instead and might be preferable.
>
> Please stop suggesting exit 0. It does not work. Hopefully the attached
> minimal testcase will convince you of this. The final "exit 0" will
> simply never be reached. run: ./foo.sh && echo $?
It will. This is why I suggest it.
| weasel@defiant:~$ cat ./tst.sh
| #!/bin/sh
| set -xe
| false && true
| exit 0
| weasel@defiant:~$ ./tst.sh
| + false
| + exit 0
| weasel@defiant:~$
> (Try also replace 'false' with 'false && true' to more exactly simulate
> your particular bug case.)
Yeah. Maybe you should try it.
> (... and even if it was reached, that would certainly throw away
> any exit code - not just the rmdir one.)
No it wouldn't.
| weasel@defiant:~$ cat ./tst2.sh
| #!/bin/sh
| set -xe
| true && false
| exit 0
| weasel@defiant:~$ ./tst2.sh
| + true
| + false
| e1:weasel@defiant:~$
--
| .''`. ** Debian **
Peter Palfrader | : :' : The universal
https://www.palfrader.org/ | `. `' Operating System
| `- https://www.debian.org/