diff options
author | April Chin <April.Chin@Sun.COM> | 2008-12-27 14:59:38 -0800 |
---|---|---|
committer | April Chin <April.Chin@Sun.COM> | 2008-12-27 14:59:38 -0800 |
commit | 7c2fbfb345896881c631598ee3852ce9ce33fb07 (patch) | |
tree | 4b173b5657508562dfc0aa05f7d056d1e9add505 /usr/src/lib/libshell/common/tests/variables.sh | |
parent | 6071ac1de68fed78e1e10052045bbb5f1732a263 (diff) | |
download | illumos-gate-7c2fbfb345896881c631598ee3852ce9ce33fb07.tar.gz |
PSARC/2008/094 ksh93 Update 1
PSARC/2008/344 ksh93 Integration Update 1 Amendments 1
PSARC/2008/589 Remove /usr/bin/printf from PSARC case 2008 094
6619428 *ksh93* RFE: Update ksh93 in Solaris to ast-ksh.2008-11-04
6788659 RFE: Update libpp in Solaris to ast-open.2008-07-25
6561901 RFE: Add "shcomp" (shell script compiler) + kernel module to exec binary sh code
6599668 RFE: Move consumers of alias.sh over to ksh93
6595183 *ksh93* RFE: Update ksh93-integration demo code
6775901 *ksh93* no C message catalogs are generated for ksh93
6451262 *sleep* RFE: /usr/bin/sleep should support floating-point values
6687139 *ksh93* command substitution, exec, and stdout redirection cause allocation loop
6703761 *ksh93* crashes in script containing uncommon output redirections
6715496 *ksh93* SEGVs on array reinitialization
6713682 *ksh93* Creating a compound variable in a subshell "bleeds through" to the calling subshell
6672350 *ksh93* causes parent shell to die when child shell is suspended
6745015 *ksh93* VARIABLE=`command substitution` assignment is not reliable on OpenSolaris
6710205 *ksh93* problem with command substitution (within back quotes) containing \$'
6737600 *ksh93* exits debugger when user presses ctrl-c
6748645 *ksh93* fc -l -e - is mis-parsed, outputs wrong error message "-e - requires single argument"
6754020 *ksh93* does weird '[' expansion
6753538 *ksh93* umask modification leaks out of a ksh93 subshell
6766246 *ksh93* bug in pattern matching
6763594 *ksh93* executes command after "command" builtin twice on failure
6762665 *ksh93* Difficult-to-reproduce SIGSEGV in ksh93
Diffstat (limited to 'usr/src/lib/libshell/common/tests/variables.sh')
-rw-r--r-- | usr/src/lib/libshell/common/tests/variables.sh | 85 |
1 files changed, 76 insertions, 9 deletions
diff --git a/usr/src/lib/libshell/common/tests/variables.sh b/usr/src/lib/libshell/common/tests/variables.sh index bc499c890c..1808d2fbcf 100644 --- a/usr/src/lib/libshell/common/tests/variables.sh +++ b/usr/src/lib/libshell/common/tests/variables.sh @@ -1,10 +1,10 @@ ######################################################################## # # # This software is part of the ast package # -# Copyright (c) 1982-2007 AT&T Knowledge Ventures # +# Copyright (c) 1982-2008 AT&T Intellectual Property # # and is licensed under the # # Common Public License, Version 1.0 # -# by AT&T Knowledge Ventures # +# by AT&T Intellectual Property # # # # A copy of the License is available at # # http://www.opensource.org/licenses/cpl1.0.txt # @@ -27,6 +27,12 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 + +[[ ${.sh.version} == "$KSH_VERSION" ]] || err_exit '.sh.version != KSH_VERSION' +unset ss +[[ ${@ss} ]] && err_exit '${@ss} should be empty string when ss is unset' +[[ ${!ss} == ss ]] || err_exit '${!ss} should be ss when ss is unset' +[[ ${#ss} == 0 ]] || err_exit '${#ss} should be 0 when ss is unset' # RANDOM if (( RANDOM==RANDOM || $RANDOM==$RANDOM )) then err_exit RANDOM variable not working @@ -97,8 +103,8 @@ fi # check for attributes across subshells typeset -i x=3 y=1/0 -if ( typeset x=y) 2> /dev/null -then print -u2 "attributes not passed to subshells" +if ( typeset x=y ) 2> /dev/null +then err_exit "attributes not passed to subshells" fi unset x function x.set @@ -249,7 +255,7 @@ set -- "${@-}" if (( $# !=1 )) then err_exit '"${@-}" not expanding to null string' fi -for i in : % + / 3b '**' '***' '@@' '{' '[' '}' !! '*a' '@a' '$foo' +for i in : % + / 3b '**' '***' '@@' '{' '[' '}' !! '*a' '$foo' do (eval : \${"$i"} 2> /dev/null) && err_exit "\${$i} not an syntax error" done unset IFS @@ -467,7 +473,7 @@ TIMEFORMAT='this is a test' : ${.sh.version} [[ $(whence rm) == *.sh.* ]] && err_exit '.sh. prefixed to tracked alias name' : ${.sh.version} -[[ $(cd /bin;env | grep PWD) == *.sh.* ]] && err_exit '.sh. prefixed to PWD' +[[ $(cd /bin;env | grep PWD=) == *.sh.* ]] && err_exit '.sh. prefixed to PWD' # unset discipline bug fix dave=dave function dave.unset @@ -476,9 +482,26 @@ function dave.unset } unset dave [[ $(typeset +f) == *dave.* ]] && err_exit 'unset discipline not removed' -print 'print ${VAR}' > /tmp/script$$ -VAR=foo /tmp/script$$ > /tmp/out$$ -[[ $(</tmp/out$$) == foo ]] || err_exit 'environment variables not passed to scripts' + +print 'print ${VAR}' > /tmp/script$$ +unset VAR +VAR=new /tmp/script$$ > /tmp/out$$ +got=$(</tmp/out$$) +[[ $got == new ]] || err_exit "previously unset environment variable not passed to script, expected 'new', got '$got'" +[[ ! $VAR ]] || err_exit "previously unset environment variable set after script, expected '', got '$VAR'" +unset VAR +VAR=old +VAR=new /tmp/script$$ > /tmp/out$$ +got=$(</tmp/out$$) +[[ $got == new ]] || err_exit "environment variable covering local variable not passed to script, expected 'new', got '$got'" +[[ $VAR == old ]] || err_exit "previously set local variable changed after script, expected 'old', got '$VAR'" +unset VAR +export VAR=old +VAR=new /tmp/script$$ > /tmp/out$$ +got=$(</tmp/out$$) +[[ $got == new ]] || err_exit "environment variable covering environment variable not passed to script, expected 'new', got '$got'" +[[ $VAR == old ]] || err_exit "previously set environment variable changed after script, expected 'old', got '$VAR'" + ( unset dave function dave.append @@ -555,4 +578,48 @@ x[0]=0 x[1]=1 x[2]=2 x[3]=3 [[ ${x[@]} == '12 8 5 3' ]] || err_exit 'set discipline for indexed array not working correctly' ((SECONDS=3*4)) (( SECONDS < 12 || SECONDS > 12.1 )) && err_exit "SECONDS is $SECONDS and should be close to 12" +unset a +function a.set +{ + print -r -- "${.sh.name}=${.sh.value}" +} +[[ $(a=1) == a=1 ]] || err_exit 'set discipline not working in subshell assignment' +[[ $(a=1 :) == a=1 ]] || err_exit 'set discipline not working in subshell command' + +[[ ${.sh.subshell} == 0 ]] || err_exit '${.sh.subshell} should be 0' +( + [[ ${.sh.subshell} == 1 ]] || err_exit '${.sh.subshell} should be 1' + ( + [[ ${.sh.subshell} == 2 ]] || err_exit '${.sh.subshell} should be 2' + ) +) + +set -- {1..32768} +(( $# == 32768 )) || err_exit "\$# failed -- expected 32768, got $#" +set -- + +unset r v x +path=$PATH +x=foo +for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV LINENO RANDOM SECONDS _ +do nameref r=$v + unset $v + if ( $SHELL -c "unset $v; : \$$v" ) 2>/dev/null + then [[ $r ]] && err_exit "unset $v failed -- expected '', got '$r'" + r=$x + [[ $r == $x ]] || err_exit "$v=$x failed -- expected '$x', got '$r'" + else err_exit "unset $v; : \$$v failed" + fi +done +for v in LC_ALL LC_CTYPE LC_MESSAGES LC_COLLATE LC_NUMERIC +do nameref r=$v + unset $v + [[ $r ]] && err_exit "unset $v failed -- expected '', got '$r'" + d=$($SHELL -c "$v=$x" 2>&1) + [[ $d ]] || err_exit "$v=$x failed -- expected locale diagnostic" + ( r=$x; [[ ! $r ]] ) 2>/dev/null || err_exit "$v=$x failed -- expected ''" + ( r=C; r=$x; [[ $r == C ]] ) 2>/dev/null || err_exit "$v=C; $v=$x failed -- expected 'C'" +done +PATH=$path + exit $((Errors)) |