1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 # subshell failure should cause the shell to exit silently
15 ${THIS_SH} -ce '(exit 17) ; echo "after (exit 17): $?"'
17 # pipeline failure should cause shell to exit silently
18 ${THIS_SH} -c 'set -e ; false | echo foo | while read x ; do ( exit 17 ) ; done; echo after pipeline subshell;'
20 # should be silent in posix mode
21 ${THIS_SH} -c 'set -o posix; set -e ; z=$(false;echo posix foo) ; echo $z'
22 # but echo foo in non-posix
23 ${THIS_SH} -c 'set -e ; z=$(false;echo non-posix foo) ; echo $z'
25 ${THIS_SH} -ce 'x=$(false) ; echo "x=\$(false) does not exit"'
27 ${THIS_SH} -ce '{ false; echo false in brace group does not exit; }'
28 echo after brace group failure: $?
30 ${THIS_SH} -ce '(false ; echo A $?) && echo B $?; echo C $?'; echo D $?
32 ${THIS_SH} -ce '(false ; echo A $?) ; echo B $?; echo C $?'; echo D $?
34 ${THIS_SH} -ce 'f() (false ; echo A $?); f && echo B $?; echo C $?'; echo D $?
36 ${THIS_SH} -ce 'f() (false ; echo A $?) ; f; echo B $?; echo C $?'; echo D $?
38 ${THIS_SH} -ce 'if false; echo A $?; then echo B $?; fi'; echo C $?
40 ${THIS_SH} -ce '! { false; echo A $?; } | cat; echo B $?'; echo C $?
42 ${THIS_SH} -ce '{ false; echo A $?; } | cat ; echo B $?'; echo C $?
47 echo after negation 1: $?
50 echo after negation 2: $?
53 echo after negation 3: $?
56 echo after negation 4: $?
58 { false ; echo foo; } | cat
59 echo after brace pipeline
61 false | echo foo | cat
64 false | (echo foo; false) | true
67 false | echo foo | while read x ; do ( exit 17 ) ; done | true
70 # this pipeline failure should cause the shell to exit
71 false | echo foo | false