diff --git a/src/cmd/ksh93/tests/basic.sh b/src/cmd/ksh93/tests/basic.sh index 5e894bbe6..18fd83dc1 100755 --- a/src/cmd/ksh93/tests/basic.sh +++ b/src/cmd/ksh93/tests/basic.sh @@ -357,8 +357,8 @@ fi print cat > $tmp/scriptx chmod +x $tmp/scriptx [[ $($SHELL -c "print foo | $tmp/scriptx ;:" 2> /dev/null ) == foo ]] || err_exit 'piping into script fails' -[[ $($SHELL -c 'X=1;print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}'" 2> /dev/null) == 1 ]] || err_exit 'x=1;${x:=$(..."...")} failure' -[[ $($SHELL -c 'print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}'" 2> /dev/null) == 0 ]] || err_exit '${x:=$(..."...")} failure' +[[ $($SHELL -c 'X=1;print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}" 2> /dev/null) == 1 ]] || err_exit 'x=1;${x:=$(..."...")} failure' +[[ $($SHELL -c 'print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}" 2> /dev/null) == 0 ]] || err_exit '${x:=$(..."...")} failure' if cat /dev/fd/3 >/dev/null 2>&1 || whence mkfifo > /dev/null then [[ $(cat <(print hello) ) == hello ]] || err_exit "process substitution not working outside for or while loop" $SHELL -c '[[ $(for i in 1;do cat <(print hello);done ) == hello ]]' 2> /dev/null|| err_exit "process substitution not working in for or while loop" diff --git a/src/cmd/ksh93/tests/builtins.sh b/src/cmd/ksh93/tests/builtins.sh index 911253178..76630e31f 100755 --- a/src/cmd/ksh93/tests/builtins.sh +++ b/src/cmd/ksh93/tests/builtins.sh @@ -686,7 +686,7 @@ then ( fi cd "$tmp" -$SHELL +E -i <<- \! && err_exit 'interactive shell should not exit 0 after false' +$SHELL +E -i 2>/dev/null <<- \! && err_exit 'interactive shell should not exit 0 after false' false exit ! diff --git a/src/cmd/ksh93/tests/comvario.sh b/src/cmd/ksh93/tests/comvario.sh index 24a2c28ec..0f344406b 100755 --- a/src/cmd/ksh93/tests/comvario.sh +++ b/src/cmd/ksh93/tests/comvario.sh @@ -15,24 +15,6 @@ # Florham Park NJ # # # # David Korn # -# # -######################################################################## -######################################################################## -# # -# This software is part of the ast package # -# Copyright (c) 1982-2012 AT&T Intellectual Property # -# and is licensed under the # -# Eclipse Public License, Version 1.0 # -# by AT&T Intellectual Property # -# # -# A copy of the License is available at # -# http://www.eclipse.org/org/documents/epl-v10.html # -# (with md5 checksum b35adb5213ca9657e911e9befb180842) # -# # -# Information and Software Systems Research # -# AT&T Research # -# Florham Park NJ # -# # # Roland Mainz # # # ######################################################################## @@ -41,10 +23,11 @@ function err_exit { print -u2 -n '\t' - print -u2 -r ${Command}[$1]: "${@:2}" + print -u2 -r "${Command}[$1]: ${@:2}" (( Errors++ )) } alias err_exit='err_exit $LINENO' +alias warning='err\_exit $((Errors--,LINENO)) warning:' Command=${0##*/} integer Errors=0 @@ -58,7 +41,7 @@ integer Errors=0 HAVE_signbit=0 if typeset -f .sh.math.signbit >/dev/null && (( signbit(-NaN) )) then HAVE_signbit=1 -else print -u2 "$0: warning: -lm does not support signbit(-NaN)" +else warning "-lm does not support signbit(-NaN)" fi compound bracketstat=( diff --git a/src/cmd/ksh93/tests/functions.sh b/src/cmd/ksh93/tests/functions.sh index ecd0b218a..2e25dc3e4 100755 --- a/src/cmd/ksh93/tests/functions.sh +++ b/src/cmd/ksh93/tests/functions.sh @@ -36,8 +36,9 @@ read -n4 c < $0 2> /dev/null ulimit -c 0 -binecho=$(whence -p echo) +bin_echo=$(whence -p echo) bin_sleep=$(whence -p sleep) +bin_kill=$(whence -p kill) integer foo=33 bar=bye @@ -138,7 +139,7 @@ fi if [[ $PWD != "$dir" ]] then err_exit 'cd inside nested subshell changes $PWD' fi -fun() "$binecho" hello +fun() "$bin_echo" hello if [[ $(fun) != hello ]] then err_exit one line functions not working fi @@ -1126,7 +1127,15 @@ function gosleep "$bin_sleep" 1 } x=$( - (sleep .25; pid=; ps 2>/dev/null | grep sleep | read pid extra; [[ $pid ]] && kill -- "$pid") & + ulimit -t unlimited 2>/dev/null # fork this subshell + mysubpid=${.sh.pid} # this subshell's new PID (new 93u+m feature) + ( + sleep .25 + # kill 'gosleep' by getting the PIDs that have $mysubpid as their parent PID + # (which includes this background process itself, but that's fine as we're invoking external 'kill') + pids=$(UNIX95=1 ps -o ppid= -o pid= 2>/dev/null | awk -v p=$mysubpid '$1==p { print $2 }') + [[ -n $pids ]] && "$bin_kill" $pids + ) & gosleep 2> /dev/null print ok ) diff --git a/src/cmd/ksh93/tests/io.sh b/src/cmd/ksh93/tests/io.sh index 4951c0e2b..ace60fe04 100755 --- a/src/cmd/ksh93/tests/io.sh +++ b/src/cmd/ksh93/tests/io.sh @@ -643,7 +643,7 @@ err=$( # ====== # A redirection with a null command could crash under certain circumstances (rhbz#1200534) -"$SHELL" -i >/dev/null -c ' +"$SHELL" -i >/dev/null 2>&1 -c ' function dlog { fc -ln -0 diff --git a/src/cmd/ksh93/tests/locale.sh b/src/cmd/ksh93/tests/locale.sh index 3310e118e..192711be3 100755 --- a/src/cmd/ksh93/tests/locale.sh +++ b/src/cmd/ksh93/tests/locale.sh @@ -42,6 +42,29 @@ b=$($SHELL -c '(LC_ALL=debug / 2>/dev/null); /' 2>&1 | sed -e "s,.*: *,," -e "s, b=$($SHELL -c '(LC_ALL=debug; / 2>/dev/null); /' 2>&1 | sed -e "s,.*: *,," -e "s, *\[.*,,") [[ "$b" == "$a" ]] || err_exit "locale not restored after subshell -- expected '$a', got '$b'" +# multibyte locale tests +if ((SHOPT_MULTIBYTE)) +then LC_ALL=debug + x='a<2b|>c<3d|\>e' + typeset -A exp=( + ['${x:0:1}']=a + ['${x:1:1}']='<2b|>' + ['${x:3:1}']='<3d|\>' + ['${x:4:1}']=e + ['${x:1}']='<2b|>c<3d|\>e' + ['${x: -1:1}']=e + ['${x: -2:1}']='<3d|\>' + ['${x:1:3}']='<2b|>c<3d|\>' + ['${x:1:20}']='<2b|>c<3d|\>e' + ['${x#??}']='c<3d|\>e' + ) + for i in "${!exp[@]}" + do eval "got=$i" + test "$got" = "${exp[$i]}" || err_exit "$i: expected '${exp[$i]}', got '$got'" + done + unset exp LC_ALL +fi # SHOPT_MULTIBYTE + # test shift-jis \x81\x40 ... \x81\x7E encodings # (shift char followed by 7 bit ascii) diff --git a/src/cmd/ksh93/tests/substring.sh b/src/cmd/ksh93/tests/substring.sh index 7b6594453..f72985917 100755 --- a/src/cmd/ksh93/tests/substring.sh +++ b/src/cmd/ksh93/tests/substring.sh @@ -585,20 +585,6 @@ do i=$1 shift 4 done -#multibyte locale tests -if((SHOPT_MULTIBYTE)); then -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:0:1}" == a || err_exit ${x:0:1} should be a' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1:1}" == "<2b|>" || err_exit ${x:1:1} should be <2b|>' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:3:1}" == "<3d|\\>" || err_exit ${x:3:1} should be <3d|\>' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:4:1}" == e || err_exit ${x:4:1} should bee' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1}" == "<2b|>c<3d|\\>e" || print -u2 ${x:1}" should be <2b|>c<3d|\>e' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x: -1:1}" == e || err_exit ${x: -1:1} should be e' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x: -2:1}" == "<3d|\\>" || err_exit ${x: -2:1} == <3d|\>' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1:3}" == "<2b|>c<3d|\\>" || err_exit ${x:1:3} should be <2b|>c<3d|\>' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1:20}" == "<2b|>c<3d|\\>e" || err_exit ${x:1:20} should be <2b|>c<3d|\>e' -x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x#??}" == "c<3d|\\>e" || err_exit "${x#??} should be c<3d|\>e' -fi # SHOPT_MULTIBYTE - x='a one and a two' [[ "${x//~(E)\<.\>/}" == ' one and two' ]] || err_exit "\< and \> not working in with ere's" diff --git a/src/cmd/ksh93/tests/variables.sh b/src/cmd/ksh93/tests/variables.sh index 24aa4e1ed..062b6dcb6 100755 --- a/src/cmd/ksh93/tests/variables.sh +++ b/src/cmd/ksh93/tests/variables.sh @@ -710,7 +710,7 @@ actual=$( ( echo ${.sh.subshell} | cat # left element of pipe should increase ${.sh.subshell} echo ${.sh.subshell} - ulimit -t unlimited # fork + ulimit -t unlimited 2>/dev/null # fork echo ${.sh.subshell} # should be same after forking existing virtual subshell ) echo ${.sh.subshell} # a background job should also increase ${.sh.subshell} @@ -730,7 +730,7 @@ set -- unset r v x ( - ulimit -t unlimited # TODO: this test messes up LINENO past the subshell unless we fork it + ulimit -t unlimited 2>/dev/null # TODO: this test messes up LINENO past the subshell unless we fork it x=foo for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV RANDOM SECONDS _ LINENO do nameref r=$v @@ -1082,7 +1082,7 @@ $SHELL -c ' # ====== # ${.sh.pid} should be the forked subshell's PID ( - ulimit -t unlimited + ulimit -t unlimited 2>/dev/null # fork the subshell [[ ${.sh.pid} == $$ ]] ) && err_exit "\${.sh.pid} is the same as \$$ (both are $$)"