mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix various minor problems and update the documentation (#237)
These are minor fixes I've accumulated over time. The following
changes are somewhat notable:
- Added a missing entry for 'typeset -s' to the man page.
- Add strftime(3) to the 'see also' section. This and the date(1)
addition are meant to add onto the documentation for 'printf %T'.
- Removed the man page the entry for ksh reading $PWD/.profile on
login. That feature was removed in commit aa7713c2
.
- Added date(1) to the 'see also' section of the man page.
- Note that the 'hash' command can be used instead of 'alias -t' to
workaround one of the caveats listed in the man page.
- Use an 'out of memory' error message rather than 'out of space'
when memory allocation fails.
- Replaced backticks with quotes in some places for consistency.
- Added missing documentation for the %P date format.
- Added missing documentation for the printf %Q and %p formats
(backported from ksh2020: https://github.com/att/ast/pull/1032).
- The comments that show each builtin's options have been updated.
This commit is contained in:
parent
2d7e9a0d6d
commit
814b5c6890
151 changed files with 378 additions and 378 deletions
|
@ -91,7 +91,7 @@ unalias no_such_alias && err_exit 'unalias should return non-zero for unknown al
|
|||
# ======
|
||||
# Adding a utility after resetting the hash table should work
|
||||
hash -r chmod
|
||||
[[ $(hash) == "chmod=$(whence -p chmod)" ]] || err_exit $'resetting the hash table with `hash -r \'utility\'` doesn\'t work correctly'
|
||||
[[ $(hash) == "chmod=$(whence -p chmod)" ]] || err_exit $'"hash -r \'utility\'" doesn\'t reset the hash table correctly'
|
||||
|
||||
# ======
|
||||
# Attempting to unalias a previously set alias twice should be an error
|
||||
|
|
|
@ -34,13 +34,13 @@ fi
|
|||
iarray=( one two three )
|
||||
{ iarray+= (four five six) ;} 2> /dev/null
|
||||
if [[ ${iarray[@]} != 'one two three four five six' ]]
|
||||
then err_exit 'index array append fails'
|
||||
then err_exit 'indexed array append fails'
|
||||
fi
|
||||
unset iarray
|
||||
iarray=one
|
||||
{ iarray+= (four five six) ;} 2> /dev/null
|
||||
if [[ ${iarray[@]} != 'one four five six' ]]
|
||||
then err_exit 'index array append to scalar fails'
|
||||
then err_exit 'indexed array append to scalar fails'
|
||||
fi
|
||||
typeset -A aarray
|
||||
aarray=( [1]=1 [3]=4 [xyz]=xyz )
|
||||
|
@ -68,8 +68,8 @@ fi
|
|||
unset foo
|
||||
foo[0]=(x=3)
|
||||
foo+=(x=4)
|
||||
[[ ${foo[1].x} == 4 ]] || err_exit 'compound append to index array not working'
|
||||
[[ ${foo[0].x} == 3 ]] || err_exit 'compound append to index array unsets existing variables'
|
||||
[[ ${foo[1].x} == 4 ]] || err_exit 'compound append to indexed array not working'
|
||||
[[ ${foo[0].x} == 3 ]] || err_exit 'compound append to indexed array unsets existing variables'
|
||||
|
||||
unset foo
|
||||
foo=a
|
||||
|
@ -80,23 +80,23 @@ unset x z arr
|
|||
typeset -a x=(a b)
|
||||
x+=(c d)
|
||||
exp='typeset -a x=(a b c d)'
|
||||
[[ $(typeset -p x) == "$exp" ]] || err_exit 'append (c d) to index array not working'
|
||||
[[ $(typeset -p x) == "$exp" ]] || err_exit 'append (c d) to indexed array not working'
|
||||
|
||||
typeset -a arr=(a=b b=c)
|
||||
arr+=(c=d d=e)
|
||||
exp='typeset -a arr=(a\=b b\=c c\=d d\=e)'
|
||||
[[ $(typeset -p arr) == "$exp" ]] || err_exit 'append (c=d d=e) to index array not working'
|
||||
[[ $(typeset -p arr) == "$exp" ]] || err_exit 'append (c=d d=e) to indexed array not working'
|
||||
|
||||
exp='typeset -a z=(a\=b b\=c d\=3 e f\=l)'
|
||||
typeset -a z=(a=b b=c)
|
||||
{ z+=(d=3 e f=l); } 2> /dev/null
|
||||
[[ $(typeset -p z) == "$exp" ]] || err_exit 'append (d=3 e f=l) to index array not working'
|
||||
[[ $(typeset -p z) == "$exp" ]] || err_exit 'append (d=3 e f=l) to indexed array not working'
|
||||
|
||||
unset arr2
|
||||
exp='typeset -a arr2=(b\=c :)'
|
||||
typeset -a arr2
|
||||
arr2+=(b=c :)
|
||||
[[ $(typeset -p arr2) == "$exp" ]] || err_exit 'append (b=c :) to index array not working'
|
||||
[[ $(typeset -p arr2) == "$exp" ]] || err_exit 'append (b=c :) to indexed array not working'
|
||||
|
||||
unset arr2
|
||||
exp='typeset -a arr2=(b\=c xxxxx)'
|
||||
|
@ -104,6 +104,6 @@ typeset -a arr2
|
|||
{
|
||||
arr2+=(b=c xxxxx)
|
||||
} 2> /dev/null
|
||||
[[ $(typeset -p arr2) == "$exp" ]] || err_exit 'append (b=c xxxxx) to index array not working'
|
||||
[[ $(typeset -p arr2) == "$exp" ]] || err_exit 'append (b=c xxxxx) to indexed array not working'
|
||||
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
|
@ -195,20 +195,20 @@ unset x
|
|||
integer y[3]=9 y[4]=2 i=3
|
||||
(( x = y[3] + y[4] ))
|
||||
if [[ $x != 11 ]]
|
||||
then err_exit "constant index array arithmetic failure"
|
||||
then err_exit "constant indexed array arithmetic failure"
|
||||
fi
|
||||
(( x = $empty y[3] + y[4] ))
|
||||
if [[ $x != 11 ]]
|
||||
then err_exit "empty constant index array arithmetic failure"
|
||||
then err_exit "empty constant indexed array arithmetic failure"
|
||||
fi
|
||||
(( x = y[i] + y[i+1] ))
|
||||
if [[ $x != 11 ]]
|
||||
then err_exit "variable subscript index array arithmetic failure"
|
||||
then err_exit "variable subscript indexed array arithmetic failure"
|
||||
fi
|
||||
integer a[5]=3 a[2]=4
|
||||
(( x = y[a[5]] + y[a[2]] ))
|
||||
if [[ $x != 11 ]]
|
||||
then err_exit "nested subscript index array arithmetic failure"
|
||||
then err_exit "nested subscript indexed array arithmetic failure"
|
||||
fi
|
||||
unset y
|
||||
typeset -Ai y
|
||||
|
@ -667,7 +667,7 @@ $SHELL 2> /dev/null -c 'str="0x1.df768ed398ee1e01329a130627ae0000p-1";typeset -l
|
|||
|
||||
x=(3 6 12)
|
||||
(( x[2] /= x[0]))
|
||||
(( x[2] == 4 )) || err_exit '(( x[2] /= x[0])) fails for index array'
|
||||
(( x[2] == 4 )) || err_exit '(( x[2] /= x[0])) fails for indexed array'
|
||||
|
||||
x=([0]=3 [1]=6 [2]=12)
|
||||
(( x[2] /= x[0]))
|
||||
|
@ -699,27 +699,27 @@ unset A[a]
|
|||
A[a]=(typeset -a AA)
|
||||
A[a].AA[aa]=1
|
||||
(( z += A[a].AA[aa++]++ ))
|
||||
(( z == 2 )) || err_exit "z should be '2' but is '$z' for associative array of index array arithmetic"
|
||||
(( z == 2 )) || err_exit "z should be '2' but is '$z' for associative array of indexed array arithmetic"
|
||||
(( aa == 3 )) || err_exit "subscript aa should be '3' but is '$aa' after ++"
|
||||
[[ ${A[a].AA[aa-1]} == 2 ]] || err_exit "\${A[a].AA[aa]} should be '2' but is '${A[a].AA[aa]}'" \
|
||||
'after ++ operation for associative array of index array arithmetic'
|
||||
'after ++ operation for associative array of indexed array arithmetic'
|
||||
unset A
|
||||
|
||||
typeset -a A
|
||||
A[a]=(typeset -A AA)
|
||||
A[a].AA[aa]=1
|
||||
(( z += A[a].AA[aa]++ ))
|
||||
(( z == 3 )) || err_exit "z should be '3' but is '$z' for index array of associative array arithmetic"
|
||||
(( z == 3 )) || err_exit "z should be '3' but is '$z' for indexed array of associative array arithmetic"
|
||||
[[ ${A[a].AA[aa]} == 2 ]] || err_exit "\${A[a].AA[aa]} should be '2' but is '${A[a].AA[aa]}'" \
|
||||
'after ++ operation for index array of associative array arithmetic'
|
||||
'after ++ operation for indexed array of associative array arithmetic'
|
||||
unset A[a]
|
||||
|
||||
A[a]=(typeset -a AA)
|
||||
A[a].AA[aa]=1
|
||||
(( z += A[a++].AA[aa++]++ ))
|
||||
(( z == 4 )) || err_exit "z should be '4' but is '$z' for index array of index array arithmetic"
|
||||
(( z == 4 )) || err_exit "z should be '4' but is '$z' for indexed array of indexed array arithmetic"
|
||||
[[ ${A[a-1].AA[aa-1]} == 2 ]] || err_exit "\${A[a].AA[aa]} should be '2' but is '${A[a].AA[aa]}'" \
|
||||
'after ++ operation for index array of index array arithmetic'
|
||||
'after ++ operation for indexed array of indexed array arithmetic'
|
||||
(( aa == 4 )) || err_exit "subscript aa should be '4' but is '$aa' after ++"
|
||||
(( a == 2 )) || err_exit "subscript a should be '2' but is '$a' after ++"
|
||||
unset A
|
||||
|
|
|
@ -288,13 +288,13 @@ fi
|
|||
unset x
|
||||
x=( 1 2 3)
|
||||
(x[1]=8)
|
||||
[[ ${x[1]} == 2 ]] || err_exit 'index array produce side effects in subshells'
|
||||
[[ ${x[1]} == 2 ]] || err_exit 'indexed array produce side effects in subshells'
|
||||
x=( 1 2 3)
|
||||
(
|
||||
x+=(8)
|
||||
[[ ${#x[@]} == 4 ]] || err_exit 'index array append in subshell error'
|
||||
[[ ${#x[@]} == 4 ]] || err_exit 'indexed array append in subshell error'
|
||||
)
|
||||
[[ ${#x[@]} == 3 ]] || err_exit 'index array append in subshell effects parent'
|
||||
[[ ${#x[@]} == 3 ]] || err_exit 'indexed array append in subshell effects parent'
|
||||
x=( [one]=1 [two]=2 [three]=3)
|
||||
(x[two]=8)
|
||||
[[ ${x[two]} == 2 ]] || err_exit 'associative array produce side effects in subshells'
|
||||
|
@ -310,7 +310,7 @@ integer i
|
|||
for ((i=0; i < 40; i++))
|
||||
do x[i]=$i
|
||||
done
|
||||
[[ ${#x[@]} == 40 ]] || err_exit 'index arrays losing values'
|
||||
[[ ${#x[@]} == 40 ]] || err_exit 'indexed arrays losing values'
|
||||
[[ $( ($SHELL -c 'typeset -A var; (IFS=: ; set -A var a:b:c ;print ${var[@]});:' )2>/dev/null) == 'a b c' ]] || err_exit 'change associative to index failed'
|
||||
unset foo
|
||||
[[ $(foo=good
|
||||
|
@ -482,7 +482,7 @@ function x.get
|
|||
}
|
||||
x[2]=
|
||||
z=$(: ${x[1]} )
|
||||
[[ $z == sub=1 ]] || err_exit 'get function not invoked for index array'
|
||||
[[ $z == sub=1 ]] || err_exit 'get function not invoked for indexed array'
|
||||
|
||||
unset x
|
||||
typeset -A x
|
||||
|
@ -498,8 +498,8 @@ unset y
|
|||
i=1
|
||||
a=(11 22)
|
||||
typeset -m y=a[i]
|
||||
[[ $y == 22 ]] || err_exit 'typeset -m for index array not working'
|
||||
[[ ${a[i]} || ${a[0]} != 11 ]] && err_exit 'typeset -m for index array not deleting element'
|
||||
[[ $y == 22 ]] || err_exit 'typeset -m for indexed array not working'
|
||||
[[ ${a[i]} || ${a[0]} != 11 ]] && err_exit 'typeset -m for indexed array not deleting element'
|
||||
|
||||
unset y
|
||||
a=([0]=11 [1]=22)
|
||||
|
@ -512,7 +512,7 @@ typeset -a a=( [0]="aa" [1]="bb" [2]="cc" )
|
|||
typeset -m 'j=a[0]'
|
||||
typeset -m 'a[0]=a[1]'
|
||||
typeset -m 'a[1]=j'
|
||||
[[ ${a[@]} == 'bb aa cc' ]] || err_exit 'moving index array elements not working'
|
||||
[[ ${a[@]} == 'bb aa cc' ]] || err_exit 'moving indexed array elements not working'
|
||||
unset a j
|
||||
[[ $(typeset -p a) ]] && err_exit 'unset associative array after typeset -m not working'
|
||||
|
||||
|
@ -526,12 +526,12 @@ unset a j
|
|||
z=(a b c)
|
||||
unset x
|
||||
typeset -m x[1]=z
|
||||
[[ ${x[1][@]} == 'a b c' ]] || err_exit 'moving indexed array to index array element not working'
|
||||
[[ ${x[1][@]} == 'a b c' ]] || err_exit 'moving indexed array to indexed array element not working'
|
||||
|
||||
unset x z
|
||||
z=([0]=a [1]=b [2]=c)
|
||||
typeset -m x[1]=z
|
||||
[[ ${x[1][@]} == 'a b c' ]] || err_exit 'moving associative array to index array element not working'
|
||||
[[ ${x[1][@]} == 'a b c' ]] || err_exit 'moving associative array to indexed array element not working'
|
||||
|
||||
{
|
||||
typeset -a arr=(
|
||||
|
@ -583,7 +583,7 @@ foo=( ${foo[yy]} ${foo[zz]} )
|
|||
|
||||
unset foo
|
||||
typeset -a foo=(abc=1 def=2)
|
||||
[[ ${foo[1]} == def=2 ]] || err_exit "index array with elements containing = not working"
|
||||
[[ ${foo[1]} == def=2 ]] || err_exit "indexed array with elements containing = not working"
|
||||
|
||||
unset foo
|
||||
typeset -a foo=( a b )
|
||||
|
@ -607,7 +607,7 @@ x=$(
|
|||
) 2> /dev/null
|
||||
[[ $x == "$exp" ]] || err_exit 'setting element 1 of array to compound variable failed'
|
||||
|
||||
#test for cloning a very large index array - can core dump
|
||||
# test for cloning a very large indexed array - can core dump
|
||||
(
|
||||
trap 'x=$?;exit $(( $x!=0 ))' EXIT
|
||||
$SHELL <<- \EOF
|
||||
|
|
|
@ -156,7 +156,7 @@ done
|
|||
[[ ${#ar[*]} == 9 ]] || err_exit "\${#ar[*]} is '${#ar[*]}', should be 9"
|
||||
[[ ${ar[4][4]} == 40 ]] || err_exit "ar[4][4] is '${ar[4][4]}', should be 40"
|
||||
|
||||
$SHELL 2> /dev/null -c 'compound c;float -a c.ar;(( c.ar[2][3][3] = 5))' || 'multi-dimensional arrays in arithmetic expressions not working'
|
||||
$SHELL 2> /dev/null -c 'compound c;float -a c.ar;(( c.ar[2][3][3] = 5))' || 'multidimensional arrays in arithmetic expressions not working'
|
||||
|
||||
expected='typeset -a -l -E c.ar=([2]=([3]=([3]=5) ) )'
|
||||
unset c
|
||||
|
|
|
@ -460,7 +460,7 @@ typeset -a x=( a=3 b=4)
|
|||
|
||||
unset z
|
||||
z='typeset -a q=(a b c)'
|
||||
$SHELL -c "$z; [[ \$(typeset -pa) == '$z' ]]" || err_exit 'typeset -pa does not list only index arrays'
|
||||
$SHELL -c "$z; [[ \$(typeset -pa) == '$z' ]]" || err_exit 'typeset -pa does not list only indexed arrays'
|
||||
z='typeset -C z=(foo=bar)'
|
||||
$SHELL -c "$z; [[ \$(typeset -pC) == '$z' ]]" || err_exit 'typeset -pC does not list only compound variables'
|
||||
unset y
|
||||
|
|
|
@ -249,7 +249,7 @@ $SHELL -xc '[[ abc =~ \babc\b ]]' 2> /dev/null || err_exit '[[ abc =~ \babc\b ]
|
|||
e=$($SHELL -c '[ -z "" -a -z "" ]' 2>&1)
|
||||
[[ $e ]] && err_exit "[ ... ] compatibility check failed -- $e"
|
||||
i=hell
|
||||
[[ hell0 == $i[0] ]] || err_exit 'pattern $i[0] interpreded as array ref'
|
||||
[[ hell0 == $i[0] ]] || err_exit 'pattern $i[0] interpreted as array ref'
|
||||
test '(' = ')' && err_exit '"test ( = )" should not be true'
|
||||
[[ $($SHELL -c 'case F in ~(Eilr)[a-z0-9#]) print ok;;esac' 2> /dev/null) == ok ]] || err_exit '~(Eilr) not working in case command'
|
||||
[[ $($SHELL -c "case Q in ~(Fi)q | \$'\E') print ok;;esac" 2> /dev/null) == ok ]] || err_exit '~(Fi)q | \E not working in case command'
|
||||
|
|
|
@ -84,7 +84,7 @@ hello \
|
|||
world \
|
||||
|
||||
!
|
||||
[[ $REPLY == 'hello world' ]] || err_exit "read continuation2 failed"
|
||||
[[ $REPLY == 'hello world' ]] || err_exit "read continuation 2 failed"
|
||||
print "one\ntwo" | { read line
|
||||
print $line | "$bincat" > /dev/null
|
||||
read line
|
||||
|
@ -729,20 +729,20 @@ PATH=$tmp:$PATH $SHELL <<-\EOF || err_exit "'whence' gets wrong path on init"
|
|||
EOF
|
||||
|
||||
# ======
|
||||
# `builtin -d` should not delete special builtins
|
||||
# 'builtin -d' should not delete special builtins
|
||||
(builtin -d export 2> /dev/null
|
||||
PATH=/dev/null
|
||||
whence -q export) || err_exit '`builtin -d` deletes special builtins'
|
||||
whence -q export) || err_exit "'builtin -d' deletes special builtins"
|
||||
|
||||
# ======
|
||||
# `read -r -d` should not ignore `-r`
|
||||
# 'read -r -d' should not ignore '-r'
|
||||
printf '\\\000' | read -r -d ''
|
||||
[[ $REPLY == $'\\' ]] || err_exit "read -r -d '' ignores -r"
|
||||
|
||||
# ======
|
||||
# Preceding a special builtin with `command` should disable its special properties
|
||||
# Preceding a special builtin with 'command' should disable its special properties
|
||||
foo=BUG command eval ':'
|
||||
[[ $foo == BUG ]] && err_exit '`command` fails to disable the special properties of special builtins'
|
||||
[[ $foo == BUG ]] && err_exit "'command' fails to disable the special properties of special builtins"
|
||||
|
||||
# ======
|
||||
# 'whence -f' should ignore functions
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
. "${SHTESTS_COMMON:-${0%/*}/_common}"
|
||||
|
||||
#test for compound variables
|
||||
# regression tests for compound variables
|
||||
Command=${0##*/}
|
||||
integer Errors=0
|
||||
Point=(
|
||||
|
@ -209,7 +209,7 @@ unset z
|
|||
stack=()
|
||||
typeset -a stack.items=([0]=foo [1]=bar)
|
||||
[[ ${stack.items[0]} == foo ]] || err_exit 'typeset -a variable not expanding correctly'
|
||||
$SHELL -c 'typeset -a info=( [1]=( passwd=( since=2005-07-20) ))' || err_exit 'problem with embedded index array in compound variable'
|
||||
$SHELL -c 'typeset -a info=( [1]=( passwd=( since=2005-07-20) ))' || err_exit 'problem with embedded indexed array in compound variable'
|
||||
x=(foo=([1]=(y=([2]=(z=4)))))
|
||||
[[ $x == *'.y'=* ]] && err_exit 'expansion with bogus leading . in name'
|
||||
unset z
|
||||
|
@ -453,7 +453,7 @@ typeset -C more_content=(
|
|||
)
|
||||
mica01[4]+=more_content
|
||||
expected=$'typeset -C -a mica01=([4]=(a_string=\'foo bar\';some_stuff=hello))'
|
||||
[[ $(typeset -p mica01) == "$expected" ]] || err_exit 'appened to indexed array compound variable not working'
|
||||
[[ $(typeset -p mica01) == "$expected" ]] || err_exit 'append to indexed array compound variable not working'
|
||||
|
||||
unset x
|
||||
compound x=( integer x= ; )
|
||||
|
@ -542,7 +542,7 @@ compound x=(
|
|||
)
|
||||
)
|
||||
expected='typeset -C x=(typeset -C -a nodes=([4]=());)'
|
||||
[[ $(typeset -p x) == "$expected" ]] || err_exit 'typeset -p with nested compound index array not working'
|
||||
[[ $(typeset -p x) == "$expected" ]] || err_exit 'typeset -p with nested compound indexed array not working'
|
||||
|
||||
unset v
|
||||
compound v=(
|
||||
|
@ -556,7 +556,7 @@ expected='typeset -C v=(typeset -A -l -i ar=([aa]=4 [bb]=9);)'
|
|||
unset x
|
||||
compound -a x
|
||||
x[1]=( a=1 b=2 )
|
||||
[[ $(print -v x[1]) == "${x[1]}" ]] || err_exit 'print -v x[1] not working for index array of compound variables'
|
||||
[[ $(print -v x[1]) == "${x[1]}" ]] || err_exit 'print -v x[1] not working for indexed array of compound variables'
|
||||
|
||||
unset x
|
||||
z='typeset -a x=(hello (x=12;y=5) world)'
|
||||
|
@ -588,9 +588,9 @@ compound vx=(
|
|||
)
|
||||
)
|
||||
eval "vy=$(print -C vx)"
|
||||
[[ $vx == "$vy" ]] || err_exit 'print -C with multi-dimensional array not working'
|
||||
[[ $vx == "$vy" ]] || err_exit 'print -C with multidimensional array not working'
|
||||
eval "vy=$(print -v vx)"
|
||||
[[ $vx == "$vy" ]] || err_exit 'print -v with multi-dimensional array not working'
|
||||
[[ $vx == "$vy" ]] || err_exit 'print -v with multidimensional array not working'
|
||||
|
||||
unset x
|
||||
typeset -C -A x=( [0]=(a=1) [1]=(b=2) )
|
||||
|
|
|
@ -56,7 +56,7 @@ done
|
|||
typeset -T X_t=( typeset name=aha )
|
||||
typeset -a[X_t] arr
|
||||
) 2> /dev/null
|
||||
[[ $? == 1 ]] || err_exit 'typeset -a[X_t] should generate an error message when X-t is not an enumeriation type'
|
||||
[[ $? == 1 ]] || err_exit 'typeset -a[X_t] should generate an error message when X-t is not an enumeration type'
|
||||
|
||||
typeset -a [Color_t] arr
|
||||
arr[green]=foo
|
||||
|
|
|
@ -28,7 +28,7 @@ function abspath
|
|||
cd ~-
|
||||
print $newdir/$base
|
||||
}
|
||||
#test for proper exit of shell
|
||||
# test for proper exit of shell
|
||||
builtin getconf
|
||||
ABSHELL=$(abspath)
|
||||
print exit 0 >.profile
|
||||
|
|
|
@ -271,7 +271,7 @@ set -- $(wc < $tmpfile2)
|
|||
(( $1 == 1000 )) || err_exit "heredoc $1 lines, should be 1000 lines"
|
||||
(( $2 == 4000 )) || err_exit "heredoc $2 words, should be 4000 words"
|
||||
|
||||
# comment with here document looses line number count
|
||||
# comment with here document loses line number count
|
||||
integer line=$((LINENO+5))
|
||||
function tst
|
||||
{
|
||||
|
|
|
@ -380,4 +380,3 @@ fi
|
|||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ typeset +n ref
|
|||
unset ref ar
|
||||
typeset -a arr=( 1 2 3 )
|
||||
typeset -n ref='arr[2]'
|
||||
[[ $(typeset -p ref) == *'arr[2]'* ]] || err_exit 'typeset -p ref when ref is a reference to an index array element is wrong'
|
||||
[[ $(typeset -p ref) == *'arr[2]'* ]] || err_exit 'typeset -p ref when ref is a reference to an indexed array element is wrong'
|
||||
|
||||
$SHELL 2> /dev/null -c 'function x { nameref lv=gg ; compound -A lv.c=( [4]=( x=1 )) ; } ; compound gg ; x' || err_exit 'compound array assignment with nameref in a function failed'
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ export ENV=/.$rc
|
|||
if [[ -o privileged ]]
|
||||
then
|
||||
[[ $(print env_hit | $SHELL 2>&1) == "OK" ]] &&
|
||||
err_exit 'privileged nointeractive shell reads $ENV file'
|
||||
err_exit 'privileged noninteractive shell reads $ENV file'
|
||||
[[ $(print env_hit | $SHELL -E 2>&1) == "OK" ]] &&
|
||||
err_exit 'privileged -E reads $ENV file'
|
||||
[[ $(print env_hit | $SHELL +E 2>&1) == "OK" ]] &&
|
||||
|
@ -61,7 +61,7 @@ then
|
|||
err_exit 'privileged --norc reads $ENV file'
|
||||
else
|
||||
[[ $(print env_hit | $SHELL 2>&1) == "OK" ]] &&
|
||||
err_exit 'nointeractive shell reads $ENV file'
|
||||
err_exit 'noninteractive shell reads $ENV file'
|
||||
[[ $(print env_hit | $SHELL -E 2>&1) == "OK" ]] ||
|
||||
err_exit '-E ignores $ENV file'
|
||||
[[ $(print env_hit | $SHELL +E 2>&1) == "OK" ]] &&
|
||||
|
@ -78,7 +78,7 @@ export ENV=/./dev/null
|
|||
if [[ -o privileged ]]
|
||||
then
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
|
||||
err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
|
||||
err_exit 'privileged noninteractive shell reads $HOME/.kshrc file'
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] &&
|
||||
err_exit 'privileged -E ignores empty $ENV'
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
|
||||
|
@ -89,7 +89,7 @@ then
|
|||
err_exit 'privileged --norc reads $HOME/.kshrc file'
|
||||
else
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
|
||||
err_exit 'nointeractive shell reads $HOME/.kshrc file'
|
||||
err_exit 'noninteractive shell reads $HOME/.kshrc file'
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] &&
|
||||
err_exit '-E ignores empty $ENV'
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
|
||||
|
@ -104,7 +104,7 @@ unset ENV
|
|||
if [[ -o privileged ]]
|
||||
then
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
|
||||
err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
|
||||
err_exit 'privileged noninteractive shell reads $HOME/.kshrc file'
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] &&
|
||||
err_exit 'privileged -E reads $HOME/.kshrc file'
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
|
||||
|
@ -115,7 +115,7 @@ then
|
|||
err_exit 'privileged --norc reads $HOME/.kshrc file'
|
||||
else
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
|
||||
err_exit 'nointeractive shell reads $HOME/.kshrc file'
|
||||
err_exit 'noninteractive shell reads $HOME/.kshrc file'
|
||||
[[ $(set +x; print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] ||
|
||||
err_exit '-E ignores $HOME/.kshrc file'
|
||||
[[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
|
||||
|
|
|
@ -288,7 +288,7 @@ then PATH=
|
|||
fi
|
||||
unset PATH
|
||||
if [[ $(whence rm) != /*rm ]]
|
||||
then err_exit 'unsetting path not working'
|
||||
then err_exit 'unsetting PATH not working'
|
||||
fi
|
||||
fi
|
||||
PATH=/dev:$tmp
|
||||
|
@ -442,7 +442,7 @@ print FPATH=../xxfun > $tmp/bin/.paths
|
|||
cp "$(whence -p echo)" $tmp/new/bin
|
||||
PATH=$tmp/bin:$tmp/new/bin:$PATH
|
||||
x=$(whence -p echo 2> /dev/null)
|
||||
[[ $x == "$tmp/new/bin/echo" ]] || err_exit 'nonexistant FPATH directory in .paths file causes path search to fail'
|
||||
[[ $x == "$tmp/new/bin/echo" ]] || err_exit 'nonexistent FPATH directory in .paths file causes path search to fail'
|
||||
|
||||
$SHELL 2> /dev/null <<- \EOF || err_exit 'path search problem with non-existent directories in PATH'
|
||||
builtin getconf
|
||||
|
|
|
@ -115,7 +115,7 @@ A_t r
|
|||
r.b[1]=(y=2)
|
||||
r.b[2]=(y=5)
|
||||
eval s="$r"
|
||||
[[ $r == "$s" ]] || err_exit 'expansion of type containing index array of types is incorrect'
|
||||
[[ $r == "$s" ]] || err_exit 'expansion of type containing indexed array of types is incorrect'
|
||||
eval "$(typeset -p s)"
|
||||
[[ $y == "$z" ]] || err_exit 'typeset -p z for type containing index of types is incorrect'
|
||||
unset r s
|
||||
|
@ -123,7 +123,7 @@ B_t r
|
|||
r.b[1]=(y=2)
|
||||
r.b[2]=(y=5)
|
||||
eval s="$r"
|
||||
[[ $r == "$s" ]] || err_exit 'expansion of type containing index array of types is incorrect'
|
||||
[[ $r == "$s" ]] || err_exit 'expansion of type containing indexed array of types is incorrect'
|
||||
eval "$(typeset -p s)"
|
||||
[[ $y == "$z" ]] || err_exit 'typeset -p z for type containing index of types is incorrect'
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ if [[ $(print -r s"!\2${x}\1\a!") != 's!\2\1\a!' ]]
|
|||
then err_exit 'print -r s"!\2${x}\1\a!" not equal s!\2\1\a!'
|
||||
fi
|
||||
if [[ $(print -r $'foo\n\n\n') != foo ]]
|
||||
then err_exit 'trailing newlines on comsubstitution not removed'
|
||||
then err_exit 'trailing newlines on command substitution not removed'
|
||||
fi
|
||||
unset x
|
||||
if [[ ${x:='//'} != '//' ]]
|
||||
|
|
|
@ -56,10 +56,9 @@ done
|
|||
diff "$tmp1" "$tmp2" >/dev/null 2>&1 || err_exit "files $tmp1 and $tmp2 differ"
|
||||
|
||||
# ======
|
||||
# `read -S` should handle double quotes correctly
|
||||
# 'read -S' should handle double quotes correctly
|
||||
IFS=',' read -S a b c <<<'foo,"""title"" data",bar'
|
||||
[[ $b == '"title" data' ]] || err_exit '"" inside "" not handled correctly with read -S'
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
||||
|
|
|
@ -70,9 +70,9 @@ do check_restricted "function foo { typeset $i=foobar;};foo" || err_exit "$i ca
|
|||
done
|
||||
|
||||
# ======
|
||||
# `set +r` and `set +o restricted` should not unset the restricted option
|
||||
check_restricted 'set +r' 2> /dev/null || err_exit '`set +r` unsets the restricted option'
|
||||
check_restricted 'set +o restricted' 2> /dev/null || err_exit '`set +o restricted` unsets the restricted option'
|
||||
# 'set +r' and 'set +o restricted' should not unset the restricted option
|
||||
check_restricted 'set +r' 2> /dev/null || err_exit "'set +r' unsets the restricted option"
|
||||
check_restricted 'set +o restricted' 2> /dev/null || err_exit "'set +o restricted' unsets the restricted option"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
|
@ -380,7 +380,7 @@ x=$(
|
|||
print ok
|
||||
++EOF
|
||||
)
|
||||
[[ $x == ok ]] || err_exit 'SIGPIPE exit status causes PIPE signal to be propogaged'
|
||||
[[ $x == ok ]] || err_exit 'SIGPIPE exit status causes PIPE signal to be propagated'
|
||||
|
||||
x=$(
|
||||
$SHELL <<- \EOF
|
||||
|
|
|
@ -58,7 +58,7 @@ val='(
|
|||
)'
|
||||
[[ $z == "$val" ]] || err_exit 'compound variable with mixed arrays not working'
|
||||
z.bar[1]=yesyes
|
||||
[[ ${z.bar[1]} == yesyes ]] || err_exit 'reassign of index array compound variable fails'
|
||||
[[ ${z.bar[1]} == yesyes ]] || err_exit 'reassign of indexed array compound variable fails'
|
||||
z.bar[1]=(x=12 y=5)
|
||||
[[ ${z.bar[1]} == $'(\n\tx=12\n\ty=5\n)' ]] || err_exit 'reassign array simple to compound variable fails'
|
||||
eval val="$z"
|
||||
|
@ -72,7 +72,7 @@ eval val="$z"
|
|||
z.foo[two]=ok
|
||||
[[ ${z.foo[two]} == ok ]] || err_exit 'associative array assignment to compound variable in subshell not working'
|
||||
z.bar[1]=yes
|
||||
[[ ${z.bar[1]} == yes ]] || err_exit 'index array assignment to compound variable in subshell not working'
|
||||
[[ ${z.bar[1]} == yes ]] || err_exit 'indexed array assignment to compound variable in subshell not working'
|
||||
)
|
||||
[[ $z == "$val" ]] || err_exit 'compound variable changes after associative array assignment'
|
||||
|
||||
|
@ -130,7 +130,7 @@ do $SHELL -c '
|
|||
(( no == (BS * nb) )) || err_exit "shell hangs on command substitution output size >= $BS*$nb with write size $bs and trailing redirection -- expected $((BS*nb)), got ${no:-0}"
|
||||
done
|
||||
|
||||
# exercise command substitutuion trailing newline logic w.r.t. pipe vs. tmp file io
|
||||
# exercise command substitution trailing newline logic w.r.t. pipe vs. tmp file io
|
||||
|
||||
set -- \
|
||||
'post-line print' \
|
||||
|
|
|
@ -501,9 +501,9 @@ fi
|
|||
{ $SHELL -c '(sleep 3;kill $$)& typeset -T x=( typeset -a s );compound c;x c.i;c.i.s[7][5][3]=hello;x c.j=c.i;[[ ${c.i} == "${c.j}" ]]';} 2> /dev/null
|
||||
exitval=$?
|
||||
if [[ $(kill -l $exitval) == TERM ]]
|
||||
then err_exit 'clone of multi-dimensional array timed out'
|
||||
then err_exit 'clone of multidimensional array timed out'
|
||||
elif ((exitval))
|
||||
then err_exit "c.i and c.j are not the same multi-dimensional array"
|
||||
then err_exit "c.i and c.j are not the same multidimensional array"
|
||||
fi
|
||||
|
||||
typeset -T foobar_t=(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue