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
304887Schintrap "rm -f /tmp/Sh$$*" EXIT
314887SchinPS3='ABC '
324887Schin
334887Schincat > /tmp/Sh$$.1 <<\!
344887Schin1) foo
354887Schin2) bar
364887Schin3) bam
374887Schin!
384887Schin
394887Schinselect i in foo bar bam
404887Schindo	case $i in
414887Schin	foo)	break;;
424887Schin	*)	err_exit "select 1 not working"
434887Schin		break;;
444887Schin	esac
454887Schindone 2> /dev/null <<!
464887Schin1
474887Schin!
484887Schin
494887Schinunset i
504887Schinselect i in foo bar bam
514887Schindo	case $i in
524887Schin	foo)	err_exit "select foo not working" 2>&3
534887Schin		break;;
544887Schin	*)	if	[[ $REPLY != foo ]]
554887Schin		then	err_exit "select REPLY not correct" 2>&3
564887Schin		fi
574887Schin		( set -u; : $i ) || err_exit "select: i not set to null" 2>&3
584887Schin		break;;
594887Schin	esac
604887Schindone  3>&2 2> /tmp/Sh$$.2 <<!
614887Schinfoo
624887Schin!
634887Schinexit $((Errors))
64