1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix xtrace (shtests -x) for the regression tests

src/cmd/ksh93/tests/{shtests,_common}:
- When xtrace is active, set SECONDS to the float type so that
  the $SECONDS expansion in $PS4 shows fractional seconds.

src/cmd/ksh93/tests/*.sh:
- Various fixes to avoid command substitutions incorporating xtrace
  output into their results. Sometimes this is done by avoiding a
  preceding assignment on a command that redirects 2>&1 (as that
  will also redirect the preceding assignment and its xtrace,
  causing the command substitution to capture the xtrace); other
  times it was easiest to just turn off xtrace outright within the
  command substitution.

src/cmd/ksh93/tests/math.sh:
- Remove an obsolete 'fixme' note.
This commit is contained in:
Martijn Dekker 2021-05-14 19:38:20 +02:00
parent 16080141c5
commit c59d888394
11 changed files with 38 additions and 21 deletions

View file

@ -772,9 +772,9 @@ v=$(printf $'%.28a\n' 64)
# https://github.com/ksh93/ksh/issues/152
exp='array_test_1: 1$(echo INJECTION >&2): arithmetic syntax error'
got=$(var='1$(echo INJECTION >&2)' "$SHELL" -c 'typeset -a a; ((a[$var]++)); typeset -p a' array_test_1 2>&1)
got=$(set +x; var='1$(echo INJECTION >&2)' "$SHELL" -c 'typeset -a a; ((a[$var]++)); typeset -p a' array_test_1 2>&1)
[[ $got == "$exp" ]] || err_exit "Array subscript quoting test 1A: expected $(printf %q "$exp"), got $(printf %q "$got")"
got=$(var='1$(echo INJECTION >&2)' "$SHELL" -c 'typeset -a a; ((a["$var"]++)); typeset -p a' array_test_1 2>&1)
got=$(set +x; var='1$(echo INJECTION >&2)' "$SHELL" -c 'typeset -a a; ((a["$var"]++)); typeset -p a' array_test_1 2>&1)
[[ $got == "$exp" ]] || err_exit "Array subscript quoting test 1B: expected $(printf %q "$exp"), got $(printf %q "$got")"
exp='typeset -A a=(['\''1$(echo INJECTION >&2)'\'']=1)'
@ -836,6 +836,7 @@ fi
integer loopcount=maxlevel+10
got=$(
typeset -r -A -i ro_arr=([a]=10 [b]=20 [c]=30)
set +x
for ((i=0; i<loopcount; i++)); do
let "ro_arr[i+1] += 5"
done 2>&1
@ -843,6 +844,7 @@ got=$(
[[ $got == *recursion* ]] && err_exit "recursion level not reset on readonly error (main shell)"
got=$(
typeset -r -A -i ro_arr=([a]=10 [b]=20 [c]=30)
set +x
for ((i=0; i<loopcount; i++)); do
( ((ro_arr[i+1] += 5)) )
done 2>&1