########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2011 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 #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# 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
function abspath
{
newdir=$(pwd)
cd ~-
}
#test for proper exit of shell
builtin getconf
print exit 0 >.profile
${ABSHELL} <<!
$(
for v in ${v//,/ }
do v=${v#*:}
v=${v%%:*}
eval [[ \$$v ]] && eval print -n \" \"\$v=\"\$$v\"
done
) \
!
status=$(echo $?)
then err_exit 'exit in .profile is ignored'
then err_exit 'privileged .profile not ignored'
fi
if [[ $(trap 'code=$?; echo $code; trap 0; exit $code' 0; exit 123) != 123 ]]
then err_exit 'exit not setting $?'
fi
trap 'code=$?; echo $code; trap 0; exit $code' 0
( trap 0; exit 123 )
then err_exit 'subshell trap on exit overwrites parent trap'
fi
cd ~- || err_exit "cd back failed"
$SHELL -c 'builtin -f cmd getconf; getconf --"?-version"; exit 0' >/dev/null 2>&1 || err_exit 'ksh plugin exit failed -- was ksh built with CCFLAGS+=$(CC.EXPORT.DYNAMIC)?'