######################################################################## # # # This software is part of the ast package # # Copyright (c) 1982-2010 AT&T Intellectual Property # # and is licensed under the # # Common Public License, Version 1.0 # # by AT&T Intellectual Property # # # # A copy of the License is available at # # http://www.opensource.org/licenses/cpl1.0.txt # # (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) # # # # Information and Software Systems Research # # AT&T Research # # Florham Park NJ # # # # David Korn # # # ######################################################################## proc err_exit { print -u2 -n "\t" print -u2 -r ${Command}[$1]: ${@:2} let Errors+=1 } alias err_exit='err_exit $LINENO' setvar Command = ${0##*/} integer Errors=0 setvar bar = 'foo2' setvar bam = "foo[3]" for i in [foo1 foo2 foo3 foo4 foo5 foo6] { setvar foo = '0' match $i { with foo1 setvar foo = '1' with $bar setvar foo = '2' with $bam setvar foo = '3' with foo[4] setvar foo = '4' with ${bar%?}5 setvar foo = '5' with "${bar%?}6" setvar foo = '6' } if [[ $i != foo$foo ]] { err_exit "$i not matching correct pattern" } } setvar f = ""[ksh92]"" match $f { with \[*\] with * err_exit "$f does not match \[*\]" } if [[ $($SHELL -c ' x=$(case abc { abc) { print yes;};; *) print no;; } ) print -r -- "$x"' 2> /dev/null) != yes ]] { err_exit 'case abc {...} not working' } [[ $($SHELL -c 'case a in a) print -n a > /dev/null ;& b) print b;; esac') != b ]] && err_exit 'bug in ;& at end of script' [[ $(VMDEBUG=1 $SHELL -c ' tmp=foo for i in a b do case $i in a) : tmp=$tmp tmp.h=$tmp.h;; b) ( tmp=bar ) for j in a do print -r -- $tmp.h done ;; esac done ') == foo.h ]] || err_exit "optimizer bug" exit $((Errors))