1 ########################################################################
3 # This software is part of the ast package #
4 # Copyright (c) 1982-2010 AT&T Intellectual Property #
5 # and is licensed under the #
6 # Common Public License, Version 1.0 #
7 # by AT&T Intellectual Property #
9 # A copy of the License is available at #
10 # http://www.opensource.org/licenses/cpl1.0.txt #
11 # (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
13 # Information and Software Systems Research #
17 # David Korn <dgk@research.att.com> #
19 ########################################################################
23 print
-u2 -r ${Command}[$1]: "${@:2}"
26 alias err_exit
='err_exit $LINENO'
31 tmp
=$
(mktemp
-dt) ||
{ err_exit mktemp
-dt failed
; exit 1; }
32 trap "cd /; rm -rf $tmp" EXIT
36 base
=$
(basename $SHELL)
42 #test for proper exit of shell
45 cd $tmp ||
{ err_exit
"cd $tmp failed"; exit 1; }
46 print
exit 0 >.profile
56 eval [[ \$
$v ]] && eval print
-n \" \"\
$v=\"\$
$v\"
59 exec -c -a -ksh ${ABSHELL} -c "exit 1" 1>/dev
/null
2>&1
62 if [[ -o noprivileged
&& $status != 0 ]]
63 then err_exit
'exit in .profile is ignored'
64 elif [[ -o privileged
&& $status == 0 ]]
65 then err_exit
'privileged .profile not ignored'
67 if [[ $
(trap 'code=$?; echo $code; trap 0; exit $code' 0; exit 123) != 123 ]]
68 then err_exit
'exit not setting $?'
70 cat > run.sh
<<- "EOF"
71 trap 'code=$?; echo $code; trap 0; exit $code' 0
74 if [[ $($SHELL ./run.sh) != 123 ]]
75 then err_exit 'subshell trap on exit overwrites parent trap'
77 cd ~- || err_exit
"cd back failed"
78 $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)?'