1*4887Schin########################################################################
2*4887Schin#                                                                      #
3*4887Schin#               This software is part of the ast package               #
4*4887Schin#           Copyright (c) 1982-2007 AT&T Knowledge Ventures            #
5*4887Schin#                      and is licensed under the                       #
6*4887Schin#                  Common Public License, Version 1.0                  #
7*4887Schin#                      by AT&T Knowledge Ventures                      #
8*4887Schin#                                                                      #
9*4887Schin#                A copy of the License is available at                 #
10*4887Schin#            http://www.opensource.org/licenses/cpl1.0.txt             #
11*4887Schin#         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         #
12*4887Schin#                                                                      #
13*4887Schin#              Information and Software Systems Research               #
14*4887Schin#                            AT&T Research                             #
15*4887Schin#                           Florham Park NJ                            #
16*4887Schin#                                                                      #
17*4887Schin#                  David Korn <dgk@research.att.com>                   #
18*4887Schin#                                                                      #
19*4887Schin########################################################################
20*4887Schinfunction err_exit
21*4887Schin{
22*4887Schin	print -u2 -n "\t"
23*4887Schin	print -u2 -r ${Command}[$1]: "${@:2}"
24*4887Schin	let Errors+=1
25*4887Schin}
26*4887Schinalias err_exit='err_exit $LINENO'
27*4887Schin
28*4887SchinCommand=${0##*/}
29*4887Schininteger Errors=0
30*4887Schintrap "rm -f /tmp/Sh$$*" EXIT
31*4887SchinPS3='ABC '
32*4887Schin
33*4887Schincat > /tmp/Sh$$.1 <<\!
34*4887Schin1) foo
35*4887Schin2) bar
36*4887Schin3) bam
37*4887Schin!
38*4887Schin
39*4887Schinselect i in foo bar bam
40*4887Schindo	case $i in
41*4887Schin	foo)	break;;
42*4887Schin	*)	err_exit "select 1 not working"
43*4887Schin		break;;
44*4887Schin	esac
45*4887Schindone 2> /dev/null <<!
46*4887Schin1
47*4887Schin!
48*4887Schin
49*4887Schinunset i
50*4887Schinselect i in foo bar bam
51*4887Schindo	case $i in
52*4887Schin	foo)	err_exit "select foo not working" 2>&3
53*4887Schin		break;;
54*4887Schin	*)	if	[[ $REPLY != foo ]]
55*4887Schin		then	err_exit "select REPLY not correct" 2>&3
56*4887Schin		fi
57*4887Schin		( set -u; : $i ) || err_exit "select: i not set to null" 2>&3
58*4887Schin		break;;
59*4887Schin	esac
60*4887Schindone  3>&2 2> /tmp/Sh$$.2 <<!
61*4887Schinfoo
62*4887Schin!
63*4887Schinexit $((Errors))
64