########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2010 AT&T Intellectual Property #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# David Korn <dgk@research.att.com> #
# #
########################################################################
function err_exit
{
print -u2 -n "\t"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
integer Errors=0
done
i=i+5
if ((i != 27))
fi
fi
if [[ $u != UPPERCASE ]]
fi
if [[ $l != lowercase ]]
fi
if [[ $n != lowercase ]]
fi
if [[ t=tagged != $(typeset -t) ]]
fi
if [[ t != $(typeset +t) ]]
fi
if [[ $Z5 != 00123 ]]
fi
if [[ $RZ5 != 00026 ]]
fi
L=12345
if [[ $L != 123 ]]
fi
if [[ $L5 != "def " ]]
fi
fi
fi
if [[ $R5 != " def" ]]
fi
fi
fi
$SHELL -c 'print \$foo'
!
)
if [[ $x != bar ]]
then err_exit 'environment variables require re-export'
fi
if [[ $? == 0 ]]
fi
a=b
readonly $a=foo
if [[ $b != foo ]]
then err_exit 'readonly $a=b not working'
fi
then err_exit 'export not working'
fi
picture=(
size=(typeset -E x=2.5)
)
if [[ "${string}" != *'size=( typeset -E'* ]]
then err_exit 'print of compound exponential variable not working'
fi
sz=(typeset -E y=2.2)
if [[ "${sz}" == *'typeset -E -F'* ]]
then err_exit 'print of exponential shows both -E and -F attributes'
fi
typeset -Z2 m
then err_exit 'attributes not cleared for script execution'
fi
typeset -Z LAST=00
unset -f foo
function foo
{
if [[ $1 ]]
then LAST=$1
fi
}
foo 1
if (( ${#LAST} != 2 ))
then err_exit 'LAST!=2'
fi
if (( ${#LAST} != 2 ))
then err_exit 'LAST!=2'
fi
set -a
unset foo
then err_exit 'all export not working'
fi
unset foo
read foo <<!
!
then err_exit 'all export not working with read'
fi
then err_exit 'typeset without arguments outputs names without attributes'
fi
unset a z q x
if (( 'a' == 97 ))
then b1=aGVsbG8gd29ybGQ=
else b1=iIWTk5ZAppaZk4Q=
fi
z=$b1
typeset -b x=$b1
typeset -b q=$x$x
x+=$b1
{
} << !
!
then [[ $(env '!=1' $SHELL -c 'echo ok' 2>/dev/null) == ok ]] || err_exit 'malformed environment terminates shell'
fi
unset var
typeset -b var
unset var
else err_exit 'typeset -usi cannot be used for unsigned short'
fi
[[ $($SHELL -c 'unset foo;typeset -Z2 foo; print ${foo:-3}' 2> /dev/null) == 3 ]] || err_exit '${foo:-3} not 3 when typeset -Z2 field undefined'
[[ $($SHELL -c 'unset foo;typeset -Z2 foo; print ${foo:=3}' 2> /dev/null) == 03 ]] || err_exit '${foo:=-3} not 3 when typeset -Z2 foo undefined'
unset -f fun
function fun
{
}
[[ $($SHELL -c 'typeset -r IFS=;print -r $(pwd)' 2> /dev/null) == "$(pwd)" ]] || err_exit 'readonly IFS causes command substitution to fail'
fred[66]=88
unset x y z
y=03
unset x z
set +a
unset z
x='typeset -i z=45'
eval "$x"
unset z
x='typeset -a z=(a b c)'
eval "$x"
unset z
x='typeset -C z=(
foo=bar
xxx=bam
)'
eval "$x"
x=${x//$'\t'}
x=${x//$'(\n'/'('}
x=${x//$'\n'/';'}
unset z
x='typeset -A z=([bar]=bam [xyz]=bar)'
eval "$x"
unset z
x='typeset -n z=foo'
eval "$x"
typeset +n z
unset foo z
typeset -T Pt_t=(
float x=1 y=2
)
Pt_t z
x=${z//$'\t'}
x=${x//$'(\n'/'('}
x=${x//$'\n'/';'}
unset z
function foo
{
typeset -p bar
}
unset foo
[[ $(typeset -p foo) == 'typeset -L 5 foo' ]] || err_exit 'typeset -p not working for variables with attributes but without a value'
{ $SHELL <<- EOF
typeset -L3 foo=aaa
typeset -L6 foo=bbbbbb
[[ \$foo == bbbbbb ]]
EOF
{ $SHELL <<- EOF
typeset -R3 foo=aaa
typeset -R6 foo=bbbbbb
[[ \$foo == bbbbbb ]]
EOF
expected='YWJjZGVmZ2hpag=='
unset foo
read foo <<< 'abcdefghijklmnop'
unset foo
unset foo
typeset -b -A foo
[[ ${foo[4]} == "$expected" ]] || err_exit 'read -N10 foo, where foo is "typeset -b -A" foo not working'
unset foo
typeset -b -a foo
[[ ${foo[4]} == "$expected" ]] || err_exit 'read -N10 foo, where foo is "typeset -b -a" foo not working'
[[ $(printf %B foo[4]) == abcdefghij ]] || err_exit 'printf %B for binary associative array element not working'
[[ $(printf %B foo[4]) == abcdefghij ]] || err_exit 'printf %B for binary indexed array element not working'
unset foo
{
# check env var changes against a builtin that uses the env var
SEC=1234252800
EDT=03
PDT=00
set -- \
while (( $# >= 4 ))
do exp=$1
[[ $got == $exp ]] || err_exit "[ '$2' '$3' '$4' ] env sequence failed -- expected '$exp', got '$got'"
shift 4
done
}
unset v