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*4887Schin 31*4887Schinbar=foo2 32*4887Schinbam=foo[3] 33*4887Schinfor i in foo1 foo2 foo3 foo4 foo5 foo6 34*4887Schindo foo=0 35*4887Schin case $i in 36*4887Schin foo1) foo=1;; 37*4887Schin $bar) foo=2;; 38*4887Schin $bam) foo=3;; 39*4887Schin foo[4]) foo=4;; 40*4887Schin ${bar%?}5) 41*4887Schin foo=5;; 42*4887Schin "${bar%?}6") 43*4887Schin foo=6;; 44*4887Schin esac 45*4887Schin if [[ $i != foo$foo ]] 46*4887Schin then err_exit "$i not matching correct pattern" 47*4887Schin fi 48*4887Schindone 49*4887Schinf="[ksh92]" 50*4887Schincase $f in 51*4887Schin\[*\]) ;; 52*4887Schin*) err_exit "$f does not match \[*\]";; 53*4887Schinesac 54*4887Schin 55*4887Schinif [[ $($SHELL -c ' 56*4887Schin x=$(case abc { 57*4887Schin abc) { print yes;};; 58*4887Schin *) print no;; 59*4887Schin } 60*4887Schin ) 61*4887Schin print -r -- "$x"' 2> /dev/null) != yes ]] 62*4887Schinthen err_exit 'case abc {...} not working' 63*4887Schinfi 64*4887Schin[[ $($SHELL -c 'case a in 65*4887Schina) print -n a > /dev/null ;& 66*4887Schinb) print b;; 67*4887Schinesac') != b ]] && err_exit 'bug in ;& at end of script' 68*4887Schin[[ $(VMDEBUG=1 $SHELL -c ' 69*4887Schin tmp=foo 70*4887Schin for i in a b 71*4887Schin do case $i in 72*4887Schin a) : tmp=$tmp tmp.h=$tmp.h;; 73*4887Schin b) ( tmp=bar ) 74*4887Schin for j in a 75*4887Schin do print -r -- $tmp.h 76*4887Schin done 77*4887Schin ;; 78*4887Schin esac 79*4887Schin done 80*4887Schin') == foo.h ]] || err_exit "optimizer bug" 81*4887Schinexit $((Errors)) 82