1# errexit-y.tst: yash-specific test of the errexit option 2 3# I think the shell should exit for all cases below, but POSIX and existing 4# implementations vary... 5 6# An expansion error in a non-interactive shell causes immediate exit of the 7# shell (regardless of errexit), so expansion errors should be tested in an 8# interactive shell. 9 10setup 'set -e' 11 12test_O -e n 'expansion error in case word' -i +m 13case ${a?} in (*) esac 14echo not reached 15__IN__ 16 17test_O -e n 'expansion error in case pattern' -i +m 18case a in (${a?}) esac 19echo not reached 20__IN__ 21 22test_O -e n 'expansion error in for word' -i +m 23for i in ${a?}; do echo not reached; done 24echo not reached 25__IN__ 26 27test_O -e n 'redirection error on subshell' 28( :; ) <_no_such_file_ 29echo not reached 30__IN__ 31 32test_O -e n 'redirection error on grouping' 33{ :; } <_no_such_file_ 34echo not reached 35__IN__ 36 37test_O -e n 'redirection error on for loop' 38for i in i; do :; done <_no_such_file_ 39echo not reached 40__IN__ 41 42test_O -e n 'redirection error on case' 43case i in esac <_no_such_file_ 44echo not reached 45__IN__ 46 47test_O -e n 'redirection error on if' 48if :; then :; fi <_no_such_file_ 49echo not reached 50__IN__ 51 52test_O -e n 'redirection error on while loop' 53while echo not reached; false; do :; done <_no_such_file_ 54echo not reached 55__IN__ 56 57test_O -e n 'redirection error on until loop' 58until echo not reached; do :; done <_no_such_file_ 59echo not reached 60__IN__ 61 62( 63if ! testee -c 'command -v [[' >/dev/null; then 64 skip="true" 65fi 66 67test_O -e 2 'expansion error in double-bracket command' -i +m 68[[ ${a?} ]] 69echo not reached 70__IN__ 71 72test_O -e 2 'redirection error on double-bracket command' 73exec 3>&1 74[[ $(echo not reached >&3) ]] <_no_such_file_ 75echo not reached 76__IN__ 77 78) 79 80# vim: set ft=sh ts=8 sts=4 sw=4 noet: 81