Peng Yu
2017-05-16 01:04:12 UTC
Hi,
I have the following code.
The exit code of the first eval is 1. The exit code of the second eval
is supposed to be 1 as well, so I'd expect the last echo to print the
exit code. But I don't see it.
Does anybody know how to understand this code?
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
( eval 'set -e; false; echo xx' )
echo xxx "$?"
( eval 'set -e; false; echo xx' ) || echo "$?"
$ ./main.sh
xxx 1
xx
I have the following code.
The exit code of the first eval is 1. The exit code of the second eval
is supposed to be 1 as well, so I'd expect the last echo to print the
exit code. But I don't see it.
Does anybody know how to understand this code?
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
( eval 'set -e; false; echo xx' )
echo xxx "$?"
( eval 'set -e; false; echo xx' ) || echo "$?"
$ ./main.sh
xxx 1
xx
--
Regards,
Peng
Regards,
Peng