Lines Matching +full:aac +full:- +full:mode

41 				# t is needed, as inside $()` $- appears to lose
46 test -z "${opt}" && continue
50 # options set, or it will mis-diagnose the situation
52 test "${#opt}" -gt 1 &&
53 CLEAR='xx="$-" && xx=$(echo "$xx" | tr -d cs) && test -n "$xx" && set +"$xx";'
55 atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
62 set -"$1"
63 t="$-"
64 x=$(echo "$t" | tr -d "$1")
70 t="$-"
71 x=$(echo "$t" | tr -d "$1")
77 # if we do not do this, -x tracing splatters stderr
78 # for some shells, -v does as well (is that correct?)
83 o="$-"
84 x=$(echo "$o" | tr -d "$opt")
104 ${TEST_SH} -c "set -${opt}" 2>/dev/null &&
108 test -n "${OPTS}" && test_option_on_off ${OPTS}
115 atf_set "descr" "Tests that 'set -a' turns on all var export " \
124 # without -a, new variables should not be exported (so grep "fails")
125 atf_check -s exit:1 -o empty -e empty ${TEST_SH} -ce \
128 # with -a, they should be
129 atf_check -s exit:0 -o match:VAR=value -e empty ${TEST_SH} -ce \
130 'unset VAR; set -a; VAR=value; env | grep "^VAR="'
135 atf_set "descr" "Tests that 'set -C' turns on no clobber mode " \
146 test -z "$(ls)" || atf_skip "Test execution directory not clean"
147 test -c "/dev/null" || atf_skip "Problem with /dev/null"
152 # Check that we can redirect onto file when -C is not set
153 atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
155 D=$(ls -l Junk_File) || exit 1
158 A=$(ls -l Junk_File) || exit 1
162 # Check that we cannot redirect onto file when -C is set
163 atf_check -s exit:0 -o empty -e not-empty ${TEST_SH} -c \
165 D=$(ls -l Important_File) || exit 1
166 set -C
168 A=$(ls -l Important_File) || exit 1
172 # Check that we can append to file, even when -C is set
173 atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
175 D=$(ls -l Junk_File) || exit 1
176 set -C
178 A=$(ls -l Junk_File) || exit 1
182 # Check that we abort on attempt to redirect onto file when -Ce is set
183 atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \
185 set -Ce
190 # Last check that we can override -C for when we really need to
191 atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
193 D=$(ls -l Junk_File) || exit 1
194 set -C
196 A=$(ls -l Junk_File) || exit 1
203 atf_set "descr" "Tests that 'set -e' turns on error detection " \
209 # Check that -e does nothing if no commands fail
210 atf_check -s exit:0 -o match:I_am_OK -e empty \
211 ${TEST_SH} -c \
212 'false; printf "%s" I_am; set -e; true; printf "%s\n" _OK'
215 atf_check -s not-exit:0 -o match:I_am -o not-match:Broken -e empty \
216 ${TEST_SH} -c \
217 'false; printf "%s" I_am; set -e; false; printf "%s\n" _Broken'
219 # same, except -e this time is on from the beginning
220 atf_check -s not-exit:0 -o match:I_am -o not-match:Broken -e empty \
221 ${TEST_SH} -ec 'printf "%s" I_am; false; printf "%s\n" _Broken'
223 # More checking of -e in other places, there is lots to deal with.
228 atf_set "descr" "Tests that 'set -f' turns off pathname expansion " \
239 test -z "$(ls)" || atf_skip "Test execution directory not clean"
245 for f in a b c d e f aa ab ac ad ae aaa aab aac aad aba abc bbb ccc
250 atf_check -s exit:0 -o empty -e empty ${TEST_SH} -ec \
254 # now test expansion is different when -f is set
255 atf_check -s exit:0 -o empty -e empty ${TEST_SH} -ec \
256 'X=$(echo b*); Y=$(set -f; echo b*); test "${X}" != "${Y}"'
261 atf_set "descr" "Tests that 'set -n' supresses command execution " \
270 atf_check -s exit:0 -o empty -e empty \
271 ${TEST_SH} -enc 'echo ABANDON HOPE; echo ALL YE; echo ...'
274 atf_check -s exit:0 -o empty -e empty \
275 ${TEST_SH} -enc 'ERR; FAIL; ABANDON HOPE'
277 # but if there is a syntax error, it should be detected (w or w/o -e)
278 atf_check -s not-exit:0 -o empty -e not-empty \
279 ${TEST_SH} -enc 'echo JUMP; for frogs swim; echo in puddles'
280 atf_check -s not-exit:0 -o empty -e not-empty \
281 ${TEST_SH} -nc 'echo ABANDON HOPE; echo "ALL YE; echo ...'
282 atf_check -s not-exit:0 -o empty -e not-empty \
283 ${TEST_SH} -enc 'echo ABANDON HOPE;; echo ALL YE; echo ...'
284 atf_check -s not-exit:0 -o empty -e not-empty \
285 ${TEST_SH} -nc 'do YOU ABANDON HOPE; for all eternity?'
287 # now test enabling -n in the middle of a script
293 atf_check -s exit:0 -o match:first -o not-match:second -e empty \
294 ${TEST_SH} -c 'echo first; set -n; echo second'
295 atf_check -s exit:0 -o match:first -o not-match:third -e empty \
296 ${TEST_SH} -c 'echo first; set -n; echo second; set +n; echo third'
297 atf_check -s exit:0 -o inline:'a\nb\n' -e empty \
298 ${TEST_SH} -c 'for x in a b c d
301 a);; b);; c) set -n;; d);;
309 # the local (testing) system (signal number is $(( $XIT - 128 )) )
319 (sleep 10 & sleep 1; kill -USR1 $!; wait $!)
329 ( 129 | 1[3-9][0-9] | 2[0-4][0-9] | 25[0-5] )
331 # The script below should exit with the same code - no output
334 # "set -n" in uses like this is not exactly well defined...
337 # (they author changes to the posix shell spec - and more.)
339 atf_check -s exit:${XIT} -o empty -e empty ${TEST_SH} -c '
340 trap "set -n" USR1
341 { sleep 1; kill -USR1 $$; sleep 1; } &
353 atf_set "descr" "Tests that 'set -u' turns on unset var detection " \
360 atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \
362 # even if -u is set
363 atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -cue \
366 # and that without -u accessing an unset variable is harmless
367 atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \
370 atf_check -s exit:0 -o match:OKOK -e empty ${TEST_SH} -ce \
371 'unset X; printf "%s" ${X-OK}; echo OK'
373 # Next test that with -u set, the shell aborts on access to unset var
374 # do not use -e, want to make sure it is -u that causes abort
375 atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \
376 'unset X; set -u; echo ${X}; echo ERR'
378 atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \
379 'unset X; set -u; echo "${X}"; echo ERR'
381 # Now a bunch of accesses to unset vars, with -u, in ways that are OK
382 atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \
383 'unset X; set -u; echo ${X-GOOD}; echo OK'
384 atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \
385 'unset X; set -u; echo ${X-OK}'
386 atf_check -s exit:0 -o not-match:ERR -o match:OK -e empty \
387 ${TEST_SH} -ce 'unset X; set -u; echo ${X+ERR}; echo OK'
390 atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \
391 'unset X; set -u; echo ${X#foo}; echo ERR'
392 atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \
393 'unset X; set -u; echo ${X%%bar}; echo ERR'
395 # lastly, just while we are checking unset vars, test aborts w/o -u
396 atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \
398 atf_check -s not-exit:0 -o not-match:ERR -e match:X_NOT_SET \
399 ${TEST_SH} -c 'unset X; echo ${X?X_NOT_SET}; echo ERR'
404 atf_set "descr" "Tests that 'set -v' turns on input read echoing " \
410 # check that -v does nothing if no later input line is read
411 atf_check -s exit:0 \
412 -o match:OKOK -o not-match:echo -o not-match:printf \
413 -e empty \
414 ${TEST_SH} -ec 'printf "%s" OK; set -v; echo OK; exit 0'
417 cat <<- 'EOF' |
418 set -v
423 atf_check -s exit:0 \
424 -o match:OKOK -o not-match:echo -o not-match:printf \
425 -e match:printf -e match:OK -e match:echo \
426 -e not-match:set ${TEST_SH}
429 cat <<- 'EOF' |
430 set -v
436 atf_check -s exit:0 \
437 -o match:OKOK -o not-match:echo -o not-match:printf \
438 -e match:printf -e match:OK -e not-match:echo \
442 cat <<- 'EOF' |
443 set -v
450 atf_check -s exit:0 \
451 -o match:111222333 -o not-match:printf \
452 -o not-match:for -o not-match:do -o not-match:done \
453 -e match:printf -e match:111 -e not-match:111222 \
454 -e match:for -e match:do -e match:done \
460 atf_set "descr" "Tests that 'set -x' turns on command exec logging " \
466 # check that cmd output appears after -x is enabled
467 atf_check -s exit:0 \
468 -o match:OKOK -o not-match:echo -o not-match:printf \
469 -e not-match:printf -e match:OK -e match:echo \
470 ${TEST_SH} -ec 'printf "%s" OK; set -x; echo OK; exit 0'
472 # and that it stops again afer -x is disabled
473 atf_check -s exit:0 \
474 -o match:OKOK -o not-match:echo -o not-match:printf \
475 -e match:printf -e match:OK -e not-match:echo \
476 ${TEST_SH} -ec 'set -x; printf "%s" OK; set +x; echo OK; exit 0'
479 atf_check -s exit:0 \
480 -o match:OK -o not-match:echo \
481 -e match:OK -e match:Run:echo \
482 ${TEST_SH} -ec 'PS4=Run:; set -x; echo OK; exit 0'
490 atf_check -s exit:0 \
491 -o match:111222333 -o not-match:printf \
492 -o not-match:for \
493 -e match:printf -e match:111 -e not-match:111222 \
494 -e not-match:for -e not-match:do -e not-match:done \
495 ${TEST_SH} -ec \
496 'set -x; for i in 111 222 333; do printf "%s" $i; done; echo; exit 0'
501 test -n "$1" || { echo >&2 "Internal error"; exit 1; }
506 local -
516 local -
518 set -e
519 set -u
521 instr e "$-" && instr u "$-" && return 0
527 set -e
528 set -u
530 instr e "$-" && instr u "$-" && return 0
539 instr '[eu]' "$-" || printf %s "OK"
542 instr e "$-" && instr u "$-" && printf %s "OK"
551 atf_set "descr" "Tests that 'local -' saves and restores options. " \
558 FN="test-funcs.$$"
561 ${TEST_SH} -ec ". './${FN}'; local_opt_check" 2>/dev/null ||
562 atf_skip "sh extension 'local -' not supported by ${TEST_SH}"
564 atf_check -s exit:0 -o match:OKOK -o not-match:ERR -e empty \
565 ${TEST_SH} -ec ". './${FN}'; local_test"
570 atf_set "descr" "Tests enabling vi disables emacs (and v.v - but why?)"\
571 " Note that -V and -E are local shell additions"
578 atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c '
580 eval "case \"$-\" in
588 " on=$1 off=$2 set=$-"
591 set -V; q V E || x V E
592 set -E; q E V || x E V
593 set -V; q V E || x V E
609 atf_check -s not-exit:0 -o empty -e not-empty \
610 ${TEST_SH} -c 'set -% ; echo ERR'
619 # Cannot test -m, setting it causes test shell to fail...
621 # That is, it works if just run as "sh -c 'echo $-; set -m; echo $-'"
623 # Don't bother testing toggling -n, once on, it stays on...
626 # Cannot test -o or -c here, or the extension -s
632 # and these are extensions that might not exist (non-fatal to test)
633 # -i and -s (and -c) are posix options, but are not required to
635 # We allow for -i to work with set, as that makes some sense,
636 # -c and -s do not.
649 # and this tests the NetBSD "local -" functionality in functions.
652 # no tests for -m (no idea how to do that one)
653 # -I (no easy way to generate the EOF it ignores)
654 # -i (not sure how to test that one at the minute)
655 # -p (because we aren't going to run tests setuid)
656 # -V/-E (too much effort, and a real test would be huge)
657 # -c (because almost all the other tests test it anyway)
658 # -q (because, for now, I am lazy)
659 # -s (coming soon, hopefully)
660 # -o (really +o: again, hopefully soon)
661 # -o longname (again, just laziness, don't wait...)
662 # -h/-b (because NetBSD doesn't implement them)