14887Schin########################################################################
24887Schin#                                                                      #
34887Schin#               This software is part of the ast package               #
4*8462SApril.Chin@Sun.COM#          Copyright (c) 1982-2008 AT&T Intellectual Property          #
54887Schin#                      and is licensed under the                       #
64887Schin#                  Common Public License, Version 1.0                  #
7*8462SApril.Chin@Sun.COM#                    by AT&T Intellectual Property                     #
84887Schin#                                                                      #
94887Schin#                A copy of the License is available at                 #
104887Schin#            http://www.opensource.org/licenses/cpl1.0.txt             #
114887Schin#         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         #
124887Schin#                                                                      #
134887Schin#              Information and Software Systems Research               #
144887Schin#                            AT&T Research                             #
154887Schin#                           Florham Park NJ                            #
164887Schin#                                                                      #
174887Schin#                  David Korn <dgk@research.att.com>                   #
184887Schin#                                                                      #
194887Schin########################################################################
204887Schinfunction err_exit
214887Schin{
224887Schin	print -u2 -n "\t"
234887Schin	print -u2 -r ${Command}[$1]: "${@:2}"
244887Schin	let Errors+=1
254887Schin}
264887Schinalias err_exit='err_exit $LINENO'
274887Schin
284887SchinCommand=${0##*/}
294887Schininteger Errors=0
30*8462SApril.Chin@Sun.COM
31*8462SApril.Chin@Sun.COMunset HISTFILE
32*8462SApril.Chin@Sun.COM
334887Schinif	[[ $( ${SHELL-ksh} -s hello<<-\!
344887Schin		print $1
354887Schin		!
364887Schin	    ) != hello ]]
374887Schinthen	err_exit "${SHELL-ksh} -s not working"
384887Schinfi
394887Schinx=$(
404887Schin	set -e
414887Schin	false && print bad
424887Schin	print good
434887Schin)
444887Schinif	[[ $x != good ]]
454887Schinthen	err_exit 'sh -e not workuing'
464887Schinfi
474887Schin[[ $($SHELL -D -c 'print hi; print $"hello"') == '"hello"' ]] || err_exit 'ksh -D not working'
484887Schin
494887Schintmp=/tmp/ksh$$
504887Schinmkdir $tmp
514887Schinrc=$tmp/.kshrc
52*8462SApril.Chin@Sun.COMprint $'PS1=""\nfunction env_hit\n{\n\tprint OK\n}' > $rc
534887Schin
54*8462SApril.Chin@Sun.COMexport ENV='${nosysrc}'$rc
554887Schinif	[[ -o privileged ]]
564887Schinthen
57*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL 2>/dev/null) == "OK" ]] &&
584887Schin		err_exit 'privileged nointeractive shell reads $ENV file'
59*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL -E 2>/dev/null) == "OK" ]] &&
604887Schin		err_exit 'privileged -E reads $ENV file'
61*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL +E 2>/dev/null) == "OK" ]] &&
624887Schin		err_exit 'privileged +E reads $ENV file'
63*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL --rc 2>/dev/null) == "OK" ]] &&
644887Schin		err_exit 'privileged --rc reads $ENV file'
65*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL --norc 2>/dev/null) == "OK" ]] &&
664887Schin		err_exit 'privileged --norc reads $ENV file'
674887Schinelse
68*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL 2>/dev/null) == "OK" ]] &&
694887Schin		err_exit 'nointeractive shell reads $ENV file'
70*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL -E 2>/dev/null) == "OK" ]] ||
714887Schin		err_exit '-E ignores $ENV file'
72*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL +E 2>/dev/null) == "OK" ]] &&
734887Schin		err_exit '+E reads $ENV file'
74*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL --rc 2>/dev/null) == "OK" ]] ||
754887Schin		err_exit '--rc ignores $ENV file'
76*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL --norc 2>/dev/null) == "OK" ]] &&
774887Schin		err_exit '--norc reads $ENV file'
78*8462SApril.Chin@Sun.COM	[[ $(print env_hit | $SHELL -i 2>/dev/null) == "OK" ]] ||
79*8462SApril.Chin@Sun.COM		err_exit '-i ignores $ENV file'
804887Schinfi
814887Schin
824887Schinexport ENV=
834887Schinif	[[ -o privileged ]]
844887Schinthen
85*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL 2>/dev/null) == "OK" ]] &&
864887Schin		err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
87*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL -E 2>/dev/null) == "OK" ]] &&
884887Schin		err_exit 'privileged -E ignores empty $ENV'
89*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL +E 2>/dev/null) == "OK" ]] &&
904887Schin		err_exit 'privileged +E reads $HOME/.kshrc file'
91*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --rc 2>/dev/null) == "OK" ]] &&
924887Schin		err_exit 'privileged --rc ignores empty $ENV'
93*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --norc 2>/dev/null) == "OK" ]] &&
944887Schin		err_exit 'privileged --norc reads $HOME/.kshrc file'
954887Schinelse
96*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL 2>/dev/null) == "OK" ]] &&
974887Schin		err_exit 'nointeractive shell reads $HOME/.kshrc file'
98*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL -E 2>/dev/null) == "OK" ]] &&
994887Schin		err_exit '-E ignores empty $ENV'
100*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL +E 2>/dev/null) == "OK" ]] &&
1014887Schin		err_exit '+E reads $HOME/.kshrc file'
102*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --rc 2>/dev/null) == "OK" ]] &&
1034887Schin		err_exit '--rc ignores empty $ENV'
104*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --norc 2>/dev/null) == "OK" ]] &&
1054887Schin		err_exit '--norc reads $HOME/.kshrc file'
1064887Schinfi
1074887Schin
1084887Schinunset ENV
1094887Schinif	[[ -o privileged ]]
1104887Schinthen
111*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL 2>/dev/null) == "OK" ]] &&
1124887Schin		err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
113*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL -E 2>/dev/null) == "OK" ]] &&
1144887Schin		err_exit 'privileged -E reads $HOME/.kshrc file'
115*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL +E 2>/dev/null) == "OK" ]] &&
1164887Schin		err_exit 'privileged +E reads $HOME/.kshrc file'
117*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --rc 2>/dev/null) == "OK" ]] &&
1184887Schin		err_exit 'privileged --rc reads $HOME/.kshrc file'
119*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --norc 2>/dev/null) == "OK" ]] &&
1204887Schin		err_exit 'privileged --norc reads $HOME/.kshrc file'
1214887Schinelse
122*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL 2>/dev/null) == "OK" ]] &&
1234887Schin		err_exit 'nointeractive shell reads $HOME/.kshrc file'
124*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL -E 2>/dev/null) == "OK" ]] ||
1254887Schin		err_exit '-E ignores $HOME/.kshrc file'
126*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL +E 2>/dev/null) == "OK" ]] &&
1274887Schin		err_exit '+E reads $HOME/.kshrc file'
128*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --rc 2>/dev/null) == "OK" ]] ||
1294887Schin		err_exit '--rc ignores $HOME/.kshrc file'
130*8462SApril.Chin@Sun.COM	[[ $(print env_hit | HOME=$tmp $SHELL --norc 2>/dev/null) == "OK" ]] &&
1314887Schin		err_exit '--norc reads $HOME/.kshrc file'
1324887Schinfi
1334887Schin
1344887Schinrm -rf $tmp
1354887Schin
1364887Schinif	command set -G 2> /dev/null
1374887Schinthen	mkdir /tmp/ksh$$
1384887Schin	cd /tmp/ksh$$
1394887Schin	mkdir bar foo
1404887Schin	> bar.c  > bam.c
1414887Schin	> bar/foo.c > bar/bam.c
1424887Schin	> foo/bam.c
1434887Schin	set -- **.c
1444887Schin	expected='bam.c bar.c'
1454887Schin	[[ $* == $expected ]] ||
1464887Schin		err_exit "-G **.c failed -- expected '$expected', got '$*'"
1474887Schin	set -- **
1484887Schin	expected='bam.c bar bar.c bar/bam.c bar/foo.c foo foo/bam.c'
1494887Schin	[[ $* == $expected ]] ||
1504887Schin		err_exit "-G ** failed -- expected '$expected', got '$*'"
1514887Schin	set -- **/*.c
1524887Schin	expected='bam.c bar.c bar/bam.c bar/foo.c foo/bam.c'
1534887Schin	[[ $* == $expected ]] ||
1544887Schin		err_exit "-G **/*.c failed -- expected '$expected', got '$*'"
1554887Schin	set -- **/bam.c
1564887Schin	expected='bam.c bar/bam.c foo/bam.c'
1574887Schin	[[ $* == $expected ]] ||
1584887Schin		err_exit "-G **/bam.c failed -- expected '$expected', got '$*'"
1594887Schin	cd ~-
1604887Schin	rm -rf /tmp/ksh$$
1614887Schinfi
1624887Schin
1634887Schinmkdir /tmp/ksh$$
1644887Schincd /tmp/ksh$$
1654887Schint="<$$>.profile.<$$>"
1664887Schinecho "echo '$t'" > .profile
1674887Schincp $SHELL ./-ksh
1684887Schinif	[[ -o privileged ]]
1694887Schinthen
170*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL -l </dev/null 2>/dev/null) == *$t* ]] &&
1714887Schin		err_exit 'privileged -l reads .profile'
172*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL --login </dev/null 2>/dev/null) == *$t* ]] &&
1734887Schin		err_exit 'privileged --login reads .profile'
174*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL --login-shell </dev/null 2>/dev/null) == *$t* ]] &&
1754887Schin		err_exit 'privileged --login-shell reads .profile'
176*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL --login_shell </dev/null 2>/dev/null) == *$t* ]] &&
1774887Schin		err_exit 'privileged --login_shell reads .profile'
178*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD exec -a -ksh $SHELL </dev/null 2>/dev/null) == *$t* ]]  &&
1794887Schin		err_exit 'privileged exec -a -ksh ksh reads .profile'
180*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD ./-ksh -i </dev/null 2>/dev/null) == *$t* ]] &&
1814887Schin		err_exit 'privileged ./-ksh reads .profile'
182*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD ./-ksh -ip </dev/null 2>/dev/null) == *$t* ]] &&
1834887Schin		err_exit 'privileged ./-ksh -p reads .profile'
1844887Schinelse
185*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL -l </dev/null 2>/dev/null) == *$t* ]] ||
1864887Schin		err_exit '-l ignores .profile'
187*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL --login </dev/null 2>/dev/null) == *$t* ]] ||
1884887Schin		err_exit '--login ignores .profile'
189*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL --login-shell </dev/null 2>/dev/null) == *$t* ]] ||
1904887Schin		err_exit '--login-shell ignores .profile'
191*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD $SHELL --login_shell </dev/null 2>/dev/null) == *$t* ]] ||
1924887Schin		err_exit '--login_shell ignores .profile'
193*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD exec -a -ksh $SHELL </dev/null 2>/dev/null) == *$t* ]]  ||
1944887Schin		err_exit 'exec -a -ksh ksh ignores .profile'
195*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD ./-ksh -i </dev/null 2>/dev/null) == *$t* ]] ||
1964887Schin		err_exit './-ksh ignores .profile'
197*8462SApril.Chin@Sun.COM	[[ $(HOME=$PWD ./-ksh -ip </dev/null 2>/dev/null) == *$t* ]] &&
1984887Schin		err_exit './-ksh -p does not ignore .profile'
1994887Schinfi
2004887Schincd ~-
2014887Schinrm -rf /tmp/ksh$$
2024887Schin
2034887Schin
2044887Schin# { exec interactive login_shell restricted xtrace } in the following test
2054887Schin
2064887Schinfor opt in \
2074887Schin	allexport all-export all_export \
2084887Schin	bgnice bg-nice bg_nice \
2094887Schin	clobber emacs \
2104887Schin	errexit err-exit err_exit \
2114887Schin	glob \
2124887Schin	globstar glob-star glob_star \
2134887Schin	gmacs \
2144887Schin	ignoreeof ignore-eof ignore_eof \
2154887Schin	keyword log markdirs monitor notify \
2164887Schin	pipefail pipe-fail pipe_fail \
2174887Schin	trackall track-all track_all \
2184887Schin	unset verbose vi \
2194887Schin	viraw vi-raw vi_raw
2204887Schindo	old=$opt
2214887Schin	if [[ ! -o $opt ]]
2224887Schin	then	old=no$opt
2234887Schin	fi
2244887Schin
2254887Schin	set --$opt || err_exit "set --$opt failed"
2264887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2274887Schin	[[ -o no$opt ]] && err_exit "[[ -o no$opt ]] failed"
2284887Schin	[[ -o no-$opt ]] && err_exit "[[ -o no-$opt ]] failed"
2294887Schin	[[ -o no_$opt ]] && err_exit "[[ -o no_$opt ]] failed"
2304887Schin	[[ -o ?$opt ]] || err_exit "[[ -o ?$opt ]] failed"
2314887Schin	[[ -o ?no$opt ]] || err_exit "[[ -o ?no$opt ]] failed"
2324887Schin	[[ -o ?no-$opt ]] || err_exit "[[ -o ?no-$opt ]] failed"
2334887Schin	[[ -o ?no_$opt ]] || err_exit "[[ -o ?no_$opt ]] failed"
2344887Schin
2354887Schin	set --no$opt || err_exit "set --no$opt failed"
2364887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2374887Schin	[[ -o $opt ]] && err_exit "[[ -o $opt ]] failed"
2384887Schin
2394887Schin	set --no-$opt || err_exit "set --no-$opt failed"
2404887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2414887Schin	[[ -o $opt ]] && err_exit "[[ -o $opt ]] failed"
2424887Schin
2434887Schin	set --no_$opt || err_exit "set --no_$opt failed"
2444887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2454887Schin	[[ -o $opt ]] && err_exit "[[ -o $opt ]] failed"
2464887Schin
2474887Schin	set -o $opt || err_exit "set -o $opt failed"
2484887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2494887Schin	set -o $opt=1 || err_exit "set -o $opt=1 failed"
2504887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2514887Schin	set -o no$opt=0 || err_exit "set -o no$opt=0 failed"
2524887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2534887Schin	set --$opt=1 || err_exit "set --$opt=1 failed"
2544887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2554887Schin	set --no$opt=0 || err_exit "set --no$opt=0 failed"
2564887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2574887Schin
2584887Schin	set -o no$opt || err_exit "set -o no$opt failed"
2594887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2604887Schin	set -o $opt=0 || err_exit "set -o $opt=0 failed"
2614887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2624887Schin	set -o no$opt=1 || err_exit "set -o no$opt=1 failed"
2634887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2644887Schin	set --$opt=0 || err_exit "set --$opt=0 failed"
2654887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2664887Schin	set --no$opt=1 || err_exit "set --no$opt=1 failed"
2674887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2684887Schin
2694887Schin	set -o no-$opt || err_exit "set -o no-$opt failed"
2704887Schin	[[ -o no-$opt ]] || err_exit "[[ -o no-$opt ]] failed"
2714887Schin
2724887Schin	set -o no_$opt || err_exit "set -o no_$opt failed"
2734887Schin	[[ -o no_$opt ]] || err_exit "[[ -o no_$opt ]] failed"
2744887Schin
2754887Schin	set +o $opt || err_exit "set +o $opt failed"
2764887Schin	[[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
2774887Schin
2784887Schin	set +o no$opt || err_exit "set +o no$opt failed"
2794887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2804887Schin
2814887Schin	set +o no-$opt || err_exit "set +o no-$opt failed"
2824887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2834887Schin
2844887Schin	set +o no_$opt || err_exit "set +o no_$opt failed"
2854887Schin	[[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
2864887Schin
2874887Schin	set --$old
2884887Schindone
2894887Schin
2904887Schinfor opt in \
2914887Schin	exec interactive login_shell login-shell logi privileged \
2924887Schin	rc restricted xtrace
2934887Schindo	[[ -o $opt ]]
2944887Schin	y=$?
2954887Schin	[[ -o no$opt ]]
2964887Schin	n=$?
2974887Schin	case $y$n in
2984887Schin	10|01)	;;
2994887Schin	*)	err_exit "[[ -o $opt ]] == [[ -o no$opt ]]" ;;
3004887Schin	esac
3014887Schindone
3024887Schin
3034887Schinfor opt in \
3044887Schin	foo foo-bar foo_bar
3054887Schindo	if	[[ -o ?$opt ]]
3064887Schin	then	err_exit "[[ -o ?$opt ]] should fail"
3074887Schin	fi
3084887Schin	if	[[ -o ?no$opt ]]
3094887Schin	then	err_exit "[[ -o ?no$opt ]] should fail"
3104887Schin	fi
3114887Schindone
312*8462SApril.Chin@Sun.COM
313*8462SApril.Chin@Sun.COM[[ $(set +o) == $(set --state) ]] || err_exit "set --state different from set +o"
314*8462SApril.Chin@Sun.COMset -- $(set --state)
315*8462SApril.Chin@Sun.COM[[ $1 == set && $2 == --default ]] || err_exit "set --state failed -- expected 'set --default *', got '$1 $2 *'"
316*8462SApril.Chin@Sun.COMshift
317*8462SApril.Chin@Sun.COMrestore=$*
318*8462SApril.Chin@Sun.COMshift
319*8462SApril.Chin@Sun.COMoff=
320*8462SApril.Chin@Sun.COMfor opt
321*8462SApril.Chin@Sun.COMdo	case $opt in
322*8462SApril.Chin@Sun.COM	--not*)	opt=${opt/--/--no} ;;
323*8462SApril.Chin@Sun.COM	--no*)	opt=${opt/--no/--} ;;
324*8462SApril.Chin@Sun.COM	--*)	opt=${opt/--/--no} ;;
325*8462SApril.Chin@Sun.COM	esac
326*8462SApril.Chin@Sun.COM	off="$off $opt"
327*8462SApril.Chin@Sun.COMdone
328*8462SApril.Chin@Sun.COMset $off
329*8462SApril.Chin@Sun.COMstate=$(set --state)
330*8462SApril.Chin@Sun.COMdefault=$(set --default --state)
331*8462SApril.Chin@Sun.COM[[ $state == $default ]] || err_exit "set --state for default options failed: expected '$default', got '$state'"
332*8462SApril.Chin@Sun.COMset $restore
333*8462SApril.Chin@Sun.COMstate=$(set --state)
334*8462SApril.Chin@Sun.COM[[ $state == "set $restore" ]] || err_exit "set --state after restore failed: expected 'set $restore', got '$state'"
335*8462SApril.Chin@Sun.COM
3364887Schinfalse | true | true   || err_exit 'pipe not exiting exit value of last element'
3374887Schintrue | true | false   && err_exit 'pipe not exiting false'
3384887Schinset -o pipefail
3394887Schinfalse | true | true    && err_exit 'pipe with first not failing with pipefail'
3404887Schintrue | false | true    && err_exit 'pipe middle not failing with pipefail'
3414887Schintrue | true | false    && err_exit 'pipe last not failing with pipefail'
342*8462SApril.Chin@Sun.COMprint hi | (sleep 1;/bin/cat) > /dev/null || err_exit 'pipeline fails with pipefail'
343*8462SApril.Chin@Sun.COM(
344*8462SApril.Chin@Sun.COM	set -o pipefail
345*8462SApril.Chin@Sun.COM	false | true
346*8462SApril.Chin@Sun.COM	(( $? )) || err_exit 'pipe not failing in subshell with pipefail'
347*8462SApril.Chin@Sun.COM) | wc >/dev/null
348*8462SApril.Chin@Sun.COM$SHELL -c 'set -o pipefail; false | $(whence -p true);' && err_exit 'pipefail not returning failure with sh -c'
349*8462SApril.Chin@Sun.COM[[ $( set -o pipefail
350*8462SApril.Chin@Sun.COM	pipe() { date | cat > /dev/null ;}
351*8462SApril.Chin@Sun.COM	print $'1\n2' |
352*8462SApril.Chin@Sun.COM	while	read i
353*8462SApril.Chin@Sun.COM	do 	if	pipe /tmp
354*8462SApril.Chin@Sun.COM		then	{ print enter $i; sleep 2; print leave $i; } &
355*8462SApril.Chin@Sun.COM		fi
356*8462SApril.Chin@Sun.COM	done
357*8462SApril.Chin@Sun.COM	wait) == $'enter 1\nenter 2'* ]] || err_exit  '& job delayed by pipefail'
358*8462SApril.Chin@Sun.COM$SHELL -c '[[ $- == *c* ]]' || err_exit  'option c not in $-'
359*8462SApril.Chin@Sun.COMtrap 'rm -f /tmp/.profile' EXIT
360*8462SApril.Chin@Sun.COM> /tmp/.profile
361*8462SApril.Chin@Sun.COMfor i in  i l r s D E a b e f h k n r t u v  x B C G H
362*8462SApril.Chin@Sun.COMdo	HOME=/tmp ENV= $SHELL -$i  2> /dev/null <<- ++EOF++ || err_exit "option $i not in \$-"
363*8462SApril.Chin@Sun.COM	[[ \$- == *$i* ]]  ||   exit 1
364*8462SApril.Chin@Sun.COM	++EOF++
365*8462SApril.Chin@Sun.COMdone
366*8462SApril.Chin@Sun.COMletters=ilrabefhknuvxBCGE
367*8462SApril.Chin@Sun.COMinteger j=0
368*8462SApril.Chin@Sun.COMfor i in  interactive login restricted allexport notify errexit \
369*8462SApril.Chin@Sun.COM	noglob  trackall keyword noexec nounset verbose xtrace braceexpand \
370*8462SApril.Chin@Sun.COM	noclobber globstar rc
371*8462SApril.Chin@Sun.COMdo	HOME=/tmp ENV= $SHELL   -o $i  2> /dev/null <<- ++EOF++ || err_exit "option $i not equivalent to ${letters:j:1}"
372*8462SApril.Chin@Sun.COM	[[ \$- == *${letters:j:1}* ]]  ||   exit 1
373*8462SApril.Chin@Sun.COM	++EOF++
374*8462SApril.Chin@Sun.COM	((j++))
375*8462SApril.Chin@Sun.COMdone
3764887Schinexit $((Errors))
377