mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Another round of accumulated minor fixes and cleanups
Only notable changes listed below. **/Mamfile: - Do not bother redirecting standard error for 'cmp -s' to /dev/null. Normally, 'cmp -s' on Linux, macOS, *BSD, or Solaris do not not print any message. If it does, something unusual is going on and I would want to see the message. - Since we now require a POSIX shell, we can use '!'. src/cmd/ksh93/include/defs.h, src/cmd/ksh93/sh/init.c: - Remove SH_TYPE_PROFILE symbol, unused after the removal of the SHOPT_PFSH code. (re: eabd6453) src/cmd/ksh93/sh/io.c: - piperead(), slowread(): Replace redundant sffileno() calls by the variables already containing their results. (re: 50d342e4) src/cmd/ksh93/bltins/mkservice.c, rc/lib/libcmd/vmstate.c: - If these aren't compiled, define a stub function to silence the ranlib(1) warning that the .o file does not contain symbols.
This commit is contained in:
parent
8fc8c2f51c
commit
b398f33c49
42 changed files with 352 additions and 523 deletions
|
|
@ -499,6 +499,10 @@ export foo
|
|||
|
||||
# ======
|
||||
# unset exported readonly variables, combined with all other possible attributes
|
||||
(
|
||||
### begin subshell
|
||||
ulimit -t unlimited 2>/dev/null # run in forked subshell to be crash-proof
|
||||
Errors=0
|
||||
typeset -A expect=(
|
||||
[a]='typeset -x -r -a foo'
|
||||
[b]='typeset -x -r -b foo'
|
||||
|
|
@ -552,7 +556,13 @@ do unset foo
|
|||
"expected $(printf %q "${expect[$flag]}"), got $(printf %q "$actual")"
|
||||
fi
|
||||
done
|
||||
unset expect
|
||||
exit "$Errors"
|
||||
### end subshell
|
||||
)
|
||||
if let "(e=$?) > 128"
|
||||
then err_exit "typeset -x -r test crashed with SIG$(kill -l "$e")"
|
||||
else let "Errors += e"
|
||||
fi
|
||||
|
||||
unset base
|
||||
for base in 0 1 65
|
||||
|
|
@ -592,6 +602,10 @@ got=$(< $tmpfile)
|
|||
# Combining -u with -F or -E caused an incorrect variable type
|
||||
# https://github.com/ksh93/ksh/pull/163
|
||||
# Allow the last numeric type to win out
|
||||
(
|
||||
### begin subshell
|
||||
ulimit -t unlimited 2>/dev/null # run in forked subshell to be crash-proof
|
||||
Errors=0
|
||||
typeset -A expect=(
|
||||
[uF]='typeset -F a=2.0000000000'
|
||||
[Fu]='typeset -F a=2.0000000000'
|
||||
|
|
@ -632,6 +646,14 @@ unset expect
|
|||
|
||||
[[ $(typeset -iX12 -s a=2; typeset -p a) == 'typeset -X 12 a=0x1.000000000000p+1' ]] || err_exit "typeset -iX12 -s failed to become typeset -X 12 a=0x1.000000000000p+1."
|
||||
|
||||
exit "$Errors"
|
||||
### end subshell
|
||||
)
|
||||
if let "(e=$?) > 128"
|
||||
then err_exit "typeset int+float test crashed with SIG$(kill -l "$e")"
|
||||
else let "Errors += e"
|
||||
fi
|
||||
|
||||
# ======
|
||||
# Bug introduced in 0e4c4d61: could not alter the size of an existing justified string attribute
|
||||
# https://github.com/ksh93/ksh/issues/142#issuecomment-780931533
|
||||
|
|
|
|||
|
|
@ -867,6 +867,7 @@ PATH=$save_PATH
|
|||
|
||||
# ======
|
||||
# These are the regression tests for the whence builtin's '-t' flag
|
||||
((.sh.version >= 20211227)) &&
|
||||
for w in 'whence -t' 'type -t' 'whence -t -v'; do
|
||||
exp=file
|
||||
got=$($w $SHELL)
|
||||
|
|
@ -1428,6 +1429,7 @@ got="$($SHELL -i "$hist_error_leak" 2>&1)"
|
|||
|
||||
# ======
|
||||
# printf -v works as of 2021-11-18
|
||||
((.sh.version >= 20211118)) && {
|
||||
integer ver=.sh.version
|
||||
exp=ok$'\f'0000$ver$'\n'
|
||||
printf -v got 'ok\f%012d\n' $ver 2>/dev/null
|
||||
|
|
@ -1438,6 +1440,7 @@ printf -v 'got[1][two][3]' 'ok\f%012d\n' $ver 2>/dev/null
|
|||
[[ ${got[1]["two"][3]} == "$exp" ]] || err_exit "printf -v not working with array subscripts" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
unset got ver
|
||||
}
|
||||
|
||||
# ======
|
||||
# The rm builtin's -d option should remove files and empty directories without
|
||||
|
|
@ -1491,45 +1494,63 @@ fi
|
|||
# ======
|
||||
# These are regression tests for the cd command's -e and -P flags
|
||||
mkdir -p "$tmp/failpwd"
|
||||
ln -s "$tmp/failpwd" "$tmp/failpwd1"
|
||||
cd "$tmp/failpwd1"
|
||||
rm ../failpwd1
|
||||
cd "$tmp/failpwd"
|
||||
"$SHELL" -c 'cd /; exec rmdir "$1"' x "$tmp/failpwd"
|
||||
cd -P .
|
||||
got=$?; exp=0
|
||||
(( got == exp )) || err_exit "cd -P without -e exits with error status if \$PWD doesn't exist (expected $exp, got $got)"
|
||||
cd -eP .
|
||||
got=$?; exp=1
|
||||
(( got == exp )) || err_exit "cd -eP doesn't fail if \$PWD doesn't exist (expected $exp, got $got)"
|
||||
if ((.sh.version >= 20211205))
|
||||
then
|
||||
cd -eP .
|
||||
got=$?; exp=1
|
||||
(( got == exp )) || err_exit "cd -eP doesn't fail if \$PWD doesn't exist (expected $exp, got $got)"
|
||||
fi
|
||||
|
||||
cd "$tmp"
|
||||
cd -P "$tmp/notadir" >/dev/null 2>&1
|
||||
got=$?; exp=1
|
||||
(( got == exp )) || err_exit "cd -P without -e fails with wrong exit status on nonexistent dir (expected $exp, got $got)"
|
||||
cd -eP "$tmp/notadir" >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP fails with wrong exit status on nonexistent dir (expected $exp, got $got)"
|
||||
if ((.sh.version >= 20211205))
|
||||
then
|
||||
cd -eP "$tmp/notadir" >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP fails with wrong exit status on nonexistent dir (expected $exp, got $got)"
|
||||
fi
|
||||
|
||||
OLDPWD="$tmp/baddir"
|
||||
cd -P - >/dev/null 2>&1
|
||||
got=$?; exp=1
|
||||
(( got == exp )) || err_exit "cd -P without -e fails with wrong exit status on \$OLDPWD (expected $exp, got $got)"
|
||||
cd -eP - >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP fails with wrong exit status on \$OLDPWD (expected $exp, got $got)"
|
||||
if ((.sh.version >= 20211205))
|
||||
then
|
||||
cd -eP - >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP fails with wrong exit status on \$OLDPWD (expected $exp, got $got)"
|
||||
fi
|
||||
cd "$tmp" || err_exit "couldn't change directory from nonexistent dir"
|
||||
|
||||
(set -o restricted; cd -P /) >/dev/null 2>&1
|
||||
got=$?; exp=1
|
||||
(( got == exp )) || err_exit "cd -P in restricted shell has wrong exit status (expected $exp, got $got)"
|
||||
(set -o restricted; cd -eP /) >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP in restricted shell has wrong exit status (expected $exp, got $got)"
|
||||
(set -o restricted; cd -?) >/dev/null 2>&1
|
||||
if ((.sh.version >= 20211205))
|
||||
then
|
||||
(set -o restricted; cd -eP /) >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP in restricted shell has wrong exit status (expected $exp, got $got)"
|
||||
fi
|
||||
(set -o restricted; cd -\?) >/dev/null 2>&1
|
||||
got=$?; exp=1
|
||||
(( got == exp )) || err_exit "cd -? shows usage info in restricted shell and has wrong exit status (expected $exp, got $got)"
|
||||
(( got == exp )) || err_exit "cd -\\? shows usage info in restricted shell and has wrong exit status (expected $exp, got $got)"
|
||||
|
||||
(cd -P '') >/dev/null 2>&1
|
||||
got=$?; exp=1
|
||||
(( got == exp )) || err_exit "cd -P to empty string has wrong exit status (expected $exp, got $got)"
|
||||
(cd -eP '') >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP to empty string has wrong exit status (expected $exp, got $got)"
|
||||
if ((.sh.version >= 20211205))
|
||||
then
|
||||
(cd -eP '') >/dev/null 2>&1
|
||||
got=$?; exp=2
|
||||
(( got == exp )) || err_exit "cd -eP to empty string has wrong exit status (expected $exp, got $got)"
|
||||
fi
|
||||
|
||||
# ======
|
||||
# The head and tail builtins should work on files without newlines
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@
|
|||
. "${SHTESTS_COMMON:-${0%/*}/_common}"
|
||||
|
||||
# regression tests for compound variables
|
||||
Command=${0##*/}
|
||||
integer Errors=0
|
||||
|
||||
Point=(
|
||||
float x=1. y=0.
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,10 +22,7 @@
|
|||
|
||||
. "${SHTESTS_COMMON:-${0%/*}/_common}"
|
||||
|
||||
# "nounset" disabled for now
|
||||
#set -o nounset
|
||||
Command=${0##*/}
|
||||
integer Errors=0 HAVE_signbit=0
|
||||
typeset -is HAVE_signbit=0
|
||||
|
||||
if typeset -f .sh.math.signbit >/dev/null && (( signbit(-NaN) ))
|
||||
then HAVE_signbit=1
|
||||
|
|
|
|||
|
|
@ -954,6 +954,7 @@ got=$(
|
|||
[[ $got == 'test' ]] || err_exit "issue 161 hypothetical bug 2" \
|
||||
"(expected 'test', got $(printf %q "$got"))"
|
||||
got=$(
|
||||
set +x
|
||||
exec 4>&1
|
||||
foo=${ { redirect 4>&1; } 6<&2 4<&-; }
|
||||
echo "test" >&4 # => 4: cannot open [Bad file descriptor]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue