mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
bump internal libast version; various minor cleanups
These are minor things I accumulated over the last month or so. Notable changes: src/lib/libast/features/api, src/lib/libast/misc/state.c, src/lib/libast/comp/conf.tab, src/cmd/ksh93/include/defs.h: - Bump internal libast version to 20220101L. We've made a few additions to the API, at least pathicase (see71934570,ca3ec200) and astconf_long (seec2ac69b2), so this should have been done already. This also updates '/opt/ast/bin/getconf _AST_VERSION'. - Use AST_VERSION instead of outdated _AST_VERSION. - In state.c, use AST_VERSION instead of hardcoding the version. src/cmd/ksh93/sh/xec.c: - Remove 'restorefd' variable, unused as of 42becab6. - Remove 'cmdrecurse' function and SH_RUNPROG macro; this was once used by a few libcmd commands, but ast-open-archive reveals it's unused as of ast 1999-12-25. src/cmd/ksh93/sh/*.c: - Where available, use e_dot instead of "." for consistency; it is defined as an extern so we might as well use it. src/cmd/ksh93/tests/*.sh: - When reporting signal names in fails, include the SIG prefix. - Fix a broken process hang test in subshell.sh. src/lib/libast/man/sfdisc.3: - Removed. The interfaces described here never made it out of AT&T; they do not exist in any libast version in ast-open-archive. Resolves: https://github.com/ksh93/ksh/issues/426
This commit is contained in:
parent
07fc64f52b
commit
e569f23ef9
25 changed files with 58 additions and 300 deletions
|
|
@ -693,7 +693,7 @@ got=$(set +x; { "$SHELL" -c '
|
|||
echo baz # 7
|
||||
'; } 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'Redirection in DEBUG trap corrupts the trap' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# The DEBUG trap crashed when re-trapping inside a subshell
|
||||
exp=$'trap -- \': main\' EXIT\ntrap -- \': main\' ERR\ntrap -- \': main\' KEYBD\ntrap -- \': main\' DEBUG'
|
||||
|
|
@ -707,7 +707,7 @@ got=$(set +x; { "$SHELL" -c '
|
|||
done
|
||||
'; } 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'Pseudosignal trap failed when re-trapping in subshell' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# Field splitting broke upon evaluating an unquoted expansion in a DEBUG trap
|
||||
exp=$'a\nb\nc'
|
||||
|
|
@ -720,7 +720,7 @@ got=$(set +x; { "$SHELL" -c '
|
|||
printf "%s\n" "$@"
|
||||
'; } 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'Field splitting broke after executing DEBUG trap' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# The DEBUG trap had side effects on the exit status
|
||||
trap ':' DEBUG
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,7 @@ then got=$( { "$SHELL" -c '
|
|||
done
|
||||
'; } 2>&1)
|
||||
((!(e = $?))) || err_exit 'crash with alarm and IFS' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
fi
|
||||
|
||||
# ======
|
||||
|
|
|
|||
|
|
@ -1340,7 +1340,7 @@ cat >$tmp/crash_rhbz1117404.ksh <<-'EOF'
|
|||
EOF
|
||||
got=$( { "$SHELL" "$tmp/crash_rhbz1117404.ksh"; } 2>&1)
|
||||
((!(e = $?))) || err_exit 'crash while handling function-local trap' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
|
|||
|
|
@ -714,7 +714,7 @@ got=$(command -x cat <(command -x echo foo) 2>&1) || err_exit "process substitut
|
|||
exit
|
||||
' empty_redir_crash_test "$tmp"
|
||||
((!(e = $?))) || err_exit 'crash on null-command redirection with DEBUG trap' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# stdout was misdirected if an EXIT/ERR trap handler was defined in a -c script
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ e=$?
|
|||
trap - TERM INT
|
||||
[[ $sleep_pid ]] && kill $sleep_pid
|
||||
((!e)) && [[ $(<$ofile) == ok ]] || err_exit "PATH containing .paths directory:" \
|
||||
"got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$(<$ofile)")"
|
||||
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$(<$ofile)")"
|
||||
|
||||
# ======
|
||||
# Check that 'command -p' and 'command -p -v' do not use the hash table (a.k.a. tracked aliases).
|
||||
|
|
@ -560,7 +560,7 @@ trap - TERM INT
|
|||
if [[ ${ kill -l "$e"; } == KILL ]]
|
||||
then warning "'command -x' test killed, probably due to lack of memory; skipping test"
|
||||
else if let "e > 0"
|
||||
then err_exit "'command -x' test yielded exit status $e$( let "e>128" && print -n / && kill -l "$e")"
|
||||
then err_exit "'command -x' test yielded exit status $e$( let "e>128" && print -n /SIG && kill -l "$e")"
|
||||
fi
|
||||
if [[ ! -s $ofile ]]
|
||||
then err_exit "'command -x' test failed to produce output"
|
||||
|
|
@ -698,7 +698,7 @@ e=$?
|
|||
trap - TERM INT
|
||||
[[ $sleep_pid ]] && kill $sleep_pid
|
||||
((e == 127)) || err_exit "Long nonexistent command name:" \
|
||||
"got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$(<$ofile)")"
|
||||
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$(<$ofile)")"
|
||||
|
||||
# ======
|
||||
# A function autoload recursion loop used to crash
|
||||
|
|
@ -716,7 +716,7 @@ $SHELL: function, built-in or type definition for self2 not found in $tmp/fun.$$
|
|||
$SHELL: function, built-in or type definition for self not found in $tmp/fun.$$/self"
|
||||
got=$({ FPATH=$tmp/fun.$$ "$SHELL" -c self; } 2>&1)
|
||||
(((e = $?) == 126)) || err_exit 'Function autoload recursion loop:' \
|
||||
"got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got")"
|
||||
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got")"
|
||||
|
||||
# ======
|
||||
# If a shared-state ${ command substitution; } changed the value of $PATH, the variable
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ got=$(export sig; "$SHELL" -c '
|
|||
trap - "$sig"
|
||||
' 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit "failed to handle SIG$sig from subshell" \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
got=$(export sig; "$SHELL" -c '
|
||||
function tryTrap
|
||||
|
|
@ -508,7 +508,7 @@ got=$(export sig; "$SHELL" -c '
|
|||
trap - "$sig"
|
||||
' 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit "failed to handle SIG$sig from ksh function" \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# ksh-style functions didn't handle signals other than SIGINT and SIGQUIT (rhbz#1454804)
|
||||
|
|
@ -526,7 +526,7 @@ got=$(export exp; "$SHELL" -c '
|
|||
' 2>&1)
|
||||
got=${got% } # rm final space
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit "ksh function ignores global signal traps" \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# Signal incorrectly issued when function returns with status > 256 and EXIT trap is active
|
||||
|
|
|
|||
|
|
@ -551,11 +551,16 @@ $SHELL <<- \EOF
|
|||
print -u2 done
|
||||
}
|
||||
out=$(eval "foo | cat" 2>&1)
|
||||
(( ${#out} == 96011 )) || err_exit "\${#out} is ${#out} should be 96011"
|
||||
print "${#out}" >out
|
||||
EOF
|
||||
} & pid=$!
|
||||
$SHELL -c "{ sleep .4 && kill $pid ;}" 2> /dev/null
|
||||
(( $? == 0 )) && err_exit 'process has hung'
|
||||
(sleep 4; kill -s KILL "$pid" 2>/dev/null) & # another bg job to kill frozen test job
|
||||
{ wait "$pid"; } 2>/dev/null # get job's exit status, suppressing signal messages
|
||||
if ((!(e = $?)))
|
||||
then [[ $(<out) == '96011' ]] || err_exit "\${#out} is $(printf %q "$(<out)"), should be 96011"
|
||||
else err_exit "process has hung (got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
fi
|
||||
kill "$!" 2>/dev/null # kill sleep process
|
||||
|
||||
{
|
||||
x=$( $SHELL <<- \EOF
|
||||
|
|
@ -848,7 +853,7 @@ test_pid=$!
|
|||
(sleep 10; kill -s KILL "$test_pid" 2>/dev/null) & # another bg job to kill frozen test job
|
||||
sleep_pid=$!
|
||||
{ wait "$test_pid"; } 2>/dev/null # get job's exit status, suppressing signal messages
|
||||
((!(e = $?))) || err_exit "backtick comsub crash/freeze (got status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
((!(e = $?))) || err_exit "backtick comsub crash/freeze (got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
kill "$sleep_pid" 2>/dev/null
|
||||
|
||||
# ======
|
||||
|
|
@ -858,7 +863,7 @@ test_pid=$!
|
|||
(sleep 2; kill -s KILL "$test_pid" 2>/dev/null) &
|
||||
sleep_pid=$!
|
||||
{ wait "$test_pid"; } 2>/dev/null
|
||||
((!(e = $?))) || err_exit "backtick comsub hang (got status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
((!(e = $?))) || err_exit "backtick comsub hang (got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
kill "$sleep_pid" 2>/dev/null
|
||||
|
||||
# Backtick command substitution with pipe hangs when filling out pipe buffer (rhbz#1138751)
|
||||
|
|
@ -867,7 +872,7 @@ test_pid=$!
|
|||
(sleep 2; kill -s KILL "$test_pid" 2>/dev/null) &
|
||||
sleep_pid=$!
|
||||
{ wait "$test_pid"; } 2>/dev/null
|
||||
((!(e = $?))) || err_exit "backtick comsub with pipe hangs (got status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
((!(e = $?))) || err_exit "backtick comsub with pipe hangs (got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
kill "$sleep_pid" 2>/dev/null
|
||||
|
||||
# ======
|
||||
|
|
@ -924,7 +929,7 @@ cat >$tmp/crash_rhbz1117404.ksh <<-'EOF'
|
|||
EOF
|
||||
got=$( { "$SHELL" "$tmp/crash_rhbz1117404.ksh"; } 2>&1)
|
||||
((!(e = $?))) || err_exit 'crash while handling subshell trap' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# Segmentation fault when using cd in a subshell, when current directory cannot be determined
|
||||
|
|
@ -941,14 +946,14 @@ got=$(set +x; { "$SHELL" -c '(subshfn() { bad; }; cd ..; echo "subPWD: $PWD"); t
|
|||
exp="PWD=$PWD"
|
||||
got=$(set +x; { "$SHELL" -c '(cd /; (cd /)); print -r -- "PWD=$PWD"'; } 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'failed to restore nonexistent PWD on exiting a virtual subshell' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
mkdir "$tmp/recreated"
|
||||
cd "$tmp/recreated"
|
||||
tmp=$tmp "$SHELL" -c 'cd /; rmdir "$tmp/recreated"; mkdir "$tmp/recreated"'
|
||||
exp="PWD=$PWD"
|
||||
got=$(set +x; { "$SHELL" -c '(cd /); print -r -- "PWD=$PWD"'; } 2>&1)
|
||||
((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'failed to restore re-created PWD on exiting a virtual subshell' \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
cd "$tmp"
|
||||
|
||||
# ======
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ HOME=$saveHOME
|
|||
if builtin .sh.tilde 2>/dev/null
|
||||
then got=$(.sh.tilde & wait "$!" 2>&1)
|
||||
((!(e = $?))) || err_exit ".sh.tilde builtin crashes the shell" \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$got"))"
|
||||
fi
|
||||
|
||||
# ... and replaced by a proper use of discipline functions that allows customising tilde expansion.
|
||||
|
|
@ -164,7 +164,7 @@ do (
|
|||
if ((!(e = $?)))
|
||||
then read Errors <$tmp/Errors
|
||||
else err_exit ".sh.tilde.$disc discipline function crashes the shell" \
|
||||
"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$(<crashmsg)"))"
|
||||
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"), $(printf %q "$(<crashmsg)"))"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -1052,7 +1052,7 @@ $SHELL -c '
|
|||
exit $((errors + 1)) # a possible erroneous asynchronous fork would cause exit status 0
|
||||
' unset_test "$@"
|
||||
(((e = $?) == 1)) || err_exit "Failure in unsetting one or more special variables" \
|
||||
"(exit status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
"(exit status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
|
||||
# ... unset in virtual subshell inside of nested function
|
||||
$SHELL -c '
|
||||
|
|
@ -1082,7 +1082,7 @@ $SHELL -c '
|
|||
exit $((errors + 1)) # a possible erroneous asynchronous fork would cause exit status 0
|
||||
' unset_subsh_fun_test "$@"
|
||||
(((e = $?) == 1)) || err_exit "Unset of special variable(s) in a virtual subshell within a nested function fails" \
|
||||
"(exit status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
"(exit status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
|
||||
# ... readonly in subshell
|
||||
$SHELL -c '
|
||||
|
|
@ -1106,7 +1106,7 @@ $SHELL -c '
|
|||
exit $((errors + 1)) # a possible erroneous asynchronous fork would cause exit status 0
|
||||
' readonly_test "$@"
|
||||
(((e = $?) == 1)) || err_exit "Failure in making one or more special variables readonly in a subshell" \
|
||||
"(exit status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
"(exit status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
|
||||
# ... subshell leak test
|
||||
$SHELL -c '
|
||||
|
|
@ -1123,7 +1123,7 @@ $SHELL -c '
|
|||
exit $((errors + 1))
|
||||
' subshell_leak_test "$@"
|
||||
(((e = $?) == 1)) || err_exit "One or more special variables leak out of a subshell" \
|
||||
"(exit status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
"(exit status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
|
||||
# ... upper/lowercase test
|
||||
$SHELL -c '
|
||||
|
|
@ -1159,7 +1159,7 @@ $SHELL -c '
|
|||
exit $((errors + 1))
|
||||
' changecase_test "$@"
|
||||
(((e = $?) == 1)) || err_exit "typeset -l/-u doesn't work on special variables" \
|
||||
"(exit status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
"(exit status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
|
||||
# ... unset followed by launching a forked subshell
|
||||
$SHELL -c '
|
||||
|
|
@ -1176,7 +1176,7 @@ $SHELL -c '
|
|||
exit $?
|
||||
' unset_to_fork_test "$@"
|
||||
(((e = $?) == 1)) || err_exit "Failure in unsetting one or more special variables followed by launching forked subshell" \
|
||||
"(exit status $e$( ((e>128)) && print -n / && kill -l "$e"))"
|
||||
"(exit status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
|
||||
|
||||
# ======
|
||||
# ${.sh.pid} should be the forked subshell's PID
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue