1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#!/bin/sh
# vim: set filetype=sh :
# file: test.debug_env
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
# license: GNU General Public License, version 3
# description: test using environment to define debug
# see also: example.debug_env
# The following tests are included:
# (1) Run interactive without env
# (2) Run interactive with dbg_run_level
# (3) Run interactive with dbg_run_level and dbg_run_names
. ./tstlib
# change multiple + (as produced in bash set -x) to just one + (as produced in dash set -x)
shell=""
while [ $# -ne 0 ]; do
if [ "$1" = "-s" ]; then
shell="$2"
shift 2
else
echo "ERROR $0: unknown option <$1>" >&2
exit 1
fi
done
[ "$shell" ] && set -- "$@" -s "$shell"
[ "$shell" = "mksh" ] && set -- "$@" -u "$UNIFY_mksh"
[ "$shell" = "bash" ] && set -- "$@" -u "$UNIFY_bash"
bug913718_unify UNIFY_posh
[ "$shell" = "posh" ] && set -- "$@" -u "$UNIFY_posh"
[ "$shell" = "busybox sh" ] && set -- "$@" -u "$UNIFY_busybox"
cmd=$(dirname $0)/example.debug_env
bug913718_cmd
unset dbg_run_level
unset dbg_run_names
check "(1) Run interactive without env" -i "echo \"q
\"" "$@" "$cmd -a -i" \
"=== example.debug_env ===
1 dbg hello
d ... change dbg: 0
q quit
? [1] "
check "(2) Run interactive with dbg_run_level" -i "echo \"q
\"" "$@" "dbg_run_level=3 $cmd -a -i" \
"=== example.debug_env ===
1 dbg hello
d ... change dbg: 3
q quit
? [1] "
check "(3) Run interactive with dbg_run_level and dbg_run_names" -i "echo \"q
\"" "$@" "dbg_run_level=4 dbg_run_names=\"one two three\" $cmd -a -i" \
"=== example.debug_env ===
1 dbg hello
d ... change dbg: 4 one three two
q quit
? [1] "
|