attributes.sh revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Knowledge Ventures #
# #
# 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
{
} << !
!
[[ $(env '!=1' $SHELL -c 'echo ok' 2>/dev/null) == ok ]] || err_exit 'malformed environment terminates shell'
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
{
}