Lines Matching refs:err_exit

20 function err_exit
26 alias err_exit='err_exit $LINENO'
31 tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
36 : ${foo=bar} || err_exit ": failed"
37 [[ $foo == bar ]] || err_exit ": side effects failed"
39 [[ $# == 2 && $1 == - && $2 == foobar ]] || err_exit "set -- - foobar failed"
41 [[ $# == 2 && $1 == -x && $2 == foobar ]] || err_exit "set -- -x foobar failed"
42 getopts :x: foo || err_exit "getopts :x: returns false"
43 [[ $foo == x && $OPTARG == foobar ]] || err_exit "getopts :x: failed"
47 then err_exit "'getopts :r:s var -r' not working"
52 then err_exit "'getopts :d#u OPT=d OPTARG=16177' failed -- OPT=$OPT OPTARG=$OPTARG"
56 do [[ $OPTIND == $((OPTIND)) ]] || err_exit "OPTIND optimization bug"
69 [[ $OPT == S && $OPTARG == $2 ]] || err_exit "OPT=$OPT OPTARG=$OPTARG -- expected OPT=S OPTARG=$2"
73 false ${foo=bar} && err_exit "false failed"
77 [[ $REPLY == 'hello world' ]] || err_exit "read builtin failed"
80 then err_exit "IFS=: read ... not working"
86 [[ $REPLY == 'hello world' ]] || err_exit "read continuation failed"
90 [[ $REPLY == 'hello world' ]] || err_exit "read builtin failed"
96 [[ $REPLY == 'hello world' ]] || err_exit "read continuation2 failed"
109 then err_exit "read multiple continuation failed"
112 then err_exit "read from pipeline failed"
117 then err_exit "read from /dev/null failed"
120 then err_exit "print -R not working correctly"
123 then err_exit "print -- not working correctly"
127 then err_exit "%n format of printf not working"
130 [[ -w /dev/fd/1 ]] || err_exit "2<&1- with built-ins has side effects"
133 then err_exit '$0 not correct for eval'
135 $SHELL -c 'read x <<< hello' 2> /dev/null || err_exit 'syntax <<< not recognized'
136 ($SHELL -c 'read x[1] <<< hello') 2> /dev/null || err_exit 'read x[1] not working'
141 then err_exit 'unset readonly variables are not displayed'
148 then err_exit 'continue breaks out of loop'
150 (continue bad 2>/dev/null && err_exit 'continue bad should return an error')
151 (break bad 2>/dev/null && err_exit 'break bad should return an error')
152 (continue 0 2>/dev/null && err_exit 'continue 0 should return an error')
153 (break 0 2>/dev/null && err_exit 'break 0 should return an error')
162 then err_exit "$fun call in ${fun}fun breaks out of for loop"
166 then err_exit 'print -f "%b" not working'
169 then err_exit 'print -f "%P" not working'
172 then err_exit 'print -f "%(pattern)q" not working'
175 then err_exit 'break labels not working'
178 then err_exit 'command -v not working'
184 then err_exit "read -r of blank line not working"
186 mkdir -p $tmp/a/b/c 2>/dev/null || err_exit "mkdir -p failed"
187 $SHELL -c "cd $tmp/a/b; cd c" 2>/dev/null || err_exit "initial script relative cd fails"
192 [[ $got == $exp ]] || err_exit "\$(trap) failed -- expected \"$exp\", got \"$got\""
195 [[ $got == $exp ]] || err_exit "\$(trap -p TERM) failed -- expected \"$exp\", got \"$got\""
197 [[ $($SHELL -c 'trap "print ok" SIGTERM; kill -s SIGTERM $$' 2> /dev/null) == ok ]] || err_exit 'SIGTERM not recognized'
198 [[ $($SHELL -c 'trap "print ok" sigterm; kill -s sigterm $$' 2> /dev/null) == ok ]] || err_exit 'SIGTERM not recognized'
199 [[ $($SHELL -c '( trap "" TERM);kill $$;print bad' == bad) ]] 2> /dev/null && err_exit 'trap ignored in subshell causes it to be ignored by parent'
201 [[ $(kill -l $?) == HUP ]] || err_exit 'kill -1 -pid not working'
203 [[ $(kill -l $?) == HUP ]] || err_exit 'kill -n1 -pid not working'
205 [[ $(kill -l $?) == HUP ]] || err_exit 'kill -HUP -pid not working'
213 then err_exit "printf %$i not working"
217 then err_exit 'trap on EXIT not working'
220 then err_exit 'trap on EXIT not being cleared'
223 then err_exit 'whence -v test not a builtin'
227 then err_exit 'whence -v test after builtin -d incorrect'
232 then err_exit "printf $forrmat not working"
235 then err_exit 'printf \0 not working'
238 then err_exit 'printf %bx%s\n not working'
242 then err_exit 'printf %10.%s\n not working'
246 then err_exit 'printf "%10.5E" not normalizing correctly'
250 then err_exit 'printf "%g" not working correctly'
255 #FIXME#) 2> /dev/null || err_exit ksh read -s var fails
257 then err_exit 'printf is not processing formats beginning with + correctly'
260 then err_exit "printf not exiting non-zero with conversion errors"
263 then err_exit 'trap builtin terminating after --version'
266 then err_exit 'set builtin terminating after --veresion'
275 then err_exit '\f...\f not working in getopts usage strings'
278 then err_exit 'printf %H not working'
281 then err_exit 'printf %(html)q not working'
284 then err_exit 'printf %(url)q not working'
287 then err_exit 'printf %T not working'
290 then err_exit 'printf %(ere)q not working'
293 then err_exit "printf '%..:c' not working"
296 then err_exit "printf '%..*c' not working"
299 then err_exit "printf '%..:s' not working"
302 then err_exit "printf '%..*s' not working"
304 [[ $(printf '%q\n') == '' ]] || err_exit 'printf "%q" with missing arguments'
308 err_exit 'printf "%T" now'
316 then err_exit "read reading ahead on a pipe"
323 then err_exit "read -n1 failed -- expected '$exp', got '$y'"
328 then err_exit 'read of incomplete line not working correctly'
333 then err_exit 'set -f not working'
340 (( $? == 127 )) || err_exit "job known to subshell"
344 (( $? == 1 )) || err_exit "wait not saving exit value"
346 (( $? == 127 )) || err_exit "subshell job known to parent"
355 then err_exit '"name=value exec -c ..." not working'
358 [[ $? == 1 ]] || err_exit 'getopts with negative OPTIND not working'
360 [[ $OPTARG == 3 ]] || err_exit 'getopts with numerical arguments failed'
362 then err_exit 'printf %2$s %1$s not working'
384 [[ $out == $val ]] || err_exit "printf $fmt $arg failed -- expected '$val', got '$out'"
386 then [[ $err ]] || err_exit "printf $fmt $arg failed, error message expected"
387 else [[ $err ]] && err_exit "$err: printf $fmt $arg failed, error message not expected -- got '$err'"
389 (( $ret == $code )) || err_exit "printf $fmt $arg failed -- expected exit code $code, got $ret"
405 then err_exit "\$OPTIND after getopts loop incorrect -- expected ${ARGC[$i]}, got $OPTIND"
413 a|c) [[ $OPTARG ]] && err_exit "getopts $options \$OPTARG for flag $opt failed, expected \"\", got \"$OPTARG\"" ;;
414 b) [[ $OPTARG == $optarg ]] || err_exit "getopts $options \$OPTARG failed -- \"$optarg\" expected, got \"$OPTARG\"" ;;
415 *) err_exit "getopts $options failed -- got flag $opt" ;;
419 [[ $($SHELL 2> /dev/null -c 'readonly foo; getopts a: foo -a blah; echo foo') == foo ]] || err_exit 'getopts with readonly variable causes script to abort'
426 [[ $a == $exp ]] || err_exit "read -N3 here-document failed -- expected '$exp', got '$a'"
428 [[ $b == $exp ]] || err_exit "read -N1 here-document failed -- expected '$exp', got '$b'"
433 [[ $a == $exp ]] || err_exit "read -n3 here-document failed -- expected '$exp', got '$a'"
435 #[[ $a == $exp ]] || err_exit "read -N3 from pipe failed -- expected '$exp', got '$a'"
437 #[[ $b == $exp ]] || err_exit "read -N1 from pipe failed -- expected '$exp', got '$b'"
440 #[[ $a == $exp ]] || err_exit "read -n3 from pipe failed -- expected '$exp', got '$a'"
445 # read -u5 -n3 -t2 a || err_exit 'read -n3 from fifo timedout'
446 # read -u5 -n1 -t2 b || err_exit 'read -n1 from fifo timedout'
449 # [[ $a == $exp ]] || err_exit "read -n3 from fifo failed -- expected '$exp', got '$a'"
454 # read -u5 -N3 -t2 a || err_exit 'read -N3 from fifo timed out'
455 # read -u5 -N1 -t2 b || err_exit 'read -N1 from fifo timedout'
458 # [[ $a == $exp ]] || err_exit "read -N3 from fifo failed -- expected '$exp', got '$a'"
460 # [[ $b == $exp ]] || err_exit "read -N1 from fifo failed -- expected '$exp', got '$b'"
477 (( sum == n )) || err_exit "command -x processed only $sum arguments"
479 [[ $? != 1 ]] && err_exit 'incorrect exit status for command -x'
487 (( sum > n )) || err_exit "command -x processed only $sum arguments"
488 (( (sum-n)%3==0 )) || err_exit "command -x processed only $sum arguments"
489 (( sum == n+3)) && err_exit "command -x processed only $sum arguments"
491 [[ $? != 1 ]] && err_exit 'incorrect exit status for command -x'
498 done) == $'0\n0\n1\n1\n2' ]] || err_exit "DEBUG trap not working"
500 [[ $($SHELL -c 'echo -3') == -3 ]] || err_exit "echo -3 not working in ucb universe"
509 then err_exit "read -t in pipe taking $total_t secs - $(( reps * delay )) minimum - too long"
511 then err_exit "read -t in pipe taking $total_t secs - $(( reps * delay )) minimum - too fast"
513 $SHELL -c 'sleep $(printf "%a" .95)' 2> /dev/null || err_exit "sleep doesn't except %a format constants"
514 $SHELL -c 'test \( ! -e \)' 2> /dev/null ; [[ $? == 1 ]] || err_exit 'test \( ! -e \) not working'
515 [[ $(ulimit) == "$(ulimit -fS)" ]] || err_exit 'ulimit is not the same as ulimit -fS'
518 [[ $( . "$tmpfile") == "$tmpfile 2 1" ]] || err_exit 'dot command not working'
520 [[ $($SHELL -c ". $tmpfile"$'\n print ok' 2> /dev/null) == ok ]] || err_exit 'syntax error in dot command affects next command'
528 (( exitval )) && err_exit "sleep doesn't exit 0 with ALRM interupt"
529 (( sec > (del - 1) )) || err_exit "ALRM signal causes sleep to terminate prematurely -- expected 3 sec, got $sec"
533 do ( unset $i) 2>/dev/null && err_exit "unset $i should fail"
537 do unset $i || print -u2 "err_exit unset $i should not fail"
539 [[ $($SHELL -c 'y=3; unset 123 y;print $?$y') == 1 ]] 2> /dev/null || err_exit 'y is not getting unset with unset 123 y'
540 [[ $($SHELL -c 'trap foo TERM; (trap;(trap) )') == 'trap -- foo TERM' ]] || err_exit 'traps not getting reset when subshell is last process'
543 (( n == 5 )) || err_exit '\0 not working with %b format with printf'
546 [[ $($SHELL -c 'ulimit -v 15000 2>/dev/null; ulimit -t') == "$t" ]] || err_exit 'ulimit -v changes ulimit -t'
548 $SHELL 2> /dev/null -c 'cd ""' && err_exit 'cd "" not producing an error'
549 [[ $($SHELL 2> /dev/null -c 'cd "";print hi') != hi ]] && err_exit 'cd "" should not terminate script'
555 cmp -s <(print -- "$($bincat<( $bincat $out ) )") <(print -- "$(cat <( cat $out ) )") || err_exit "builtin cat differs from $bincat"
557 [[ $($SHELL -c '{ printf %R "["; print ok;}' 2> /dev/null) == ok ]] || err_exit $'\'printf %R "["\' causes shell to abort'
569 [[ $v == $'usr1\ndone' ]] || err_exit 'read not terminating when receiving USR1 signal'
575 [[ $PWD == "$pwd" ]] || err_exit 'cd ../tmpdir1 causes directory to change'
578 cd .. 2> /dev/null || err_exit 'cannot change directory to .. after current directory has been renamed'
579 [[ $PWD == "$tmp" ]] || err_exit 'after "cd $tmp/tmpdir1; cd .." directory is not $tmp'
586 cd ../.. 2> /dev/null || err_exit 'cannot change directory to ../.. after current directory has been renamed'
587 [[ $PWD == "$tmp" ]] || err_exit 'after "cd $tmp/tmpdir2; cd ../.." directory is not $tmp'
593 [[ $(pwd) == / ]] || err_exit 'cd /etc;cd ..;pwd is not /'
596 [[ $(pwd) == / ]] || err_exit 'cd /etc;cd ../..;pwd is not /'
599 [[ $(pwd) == / ]] || err_exit 'cd /etc;cd .././..;pwd is not /'
602 [[ $(pwd) == / ]] || err_exit 'cd /usr/bin;cd ../..;pwd is not /'
605 [[ $(pwd) == /usr ]] || err_exit 'cd /usr/bin;cd ..;pwd is not /usr'
616 [[ -f real_t1 ]] || err_exit 'real_t1 not found after parent directory renamed in subshell'
621 $SHELL +E -i <<- \! && err_exit 'interactive shell should not exit 0 after false'
627 then [[ $(kill -l HUP) == "$(kill -L HUP)" ]] || err_exit 'kill -l and kill -L are not the same when given a signal name'
628 [[ $(kill -l 9) == "$(kill -L 9)" ]] || err_exit 'kill -l and kill -L are not the same when given a signal number'
629 [[ $(kill -L) == *'9) KILL'* ]] || err_exit 'kill -L output does not contain 9) KILL'
634 [[ $v == 2* ]] || err_exit 'getopts --man does not exit 2 for interactive shells'
637 [[ $baz == 'foo\\bar' ]] || err_exit 'read of foo\\\\bar not getting foo\\bar'
640 [[ $(builtin) == *.sh.tilde* ]] && err_exit 'builtin contains .sh.tilde'