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*4887Schinx=abc 32*4887Schinx+=def ;} 2> /dev/null 33*4887Schinif [[ $x != abcdef ]] 34*4887Schinthen err_exit 'abc+def != abcdef' 35*4887Schinfi 36*4887Schininteger i=3 37*4887Schin{ i+=4;} 2> /dev/null 38*4887Schinif (( i != 7 )) 39*4887Schinthen err_exit '3+4!=7' 40*4887Schinfi 41*4887Schiniarray=( one two three ) 42*4887Schin{ iarray+= (four five six) ;} 2> /dev/null 43*4887Schinif [[ ${iarray[@]} != 'one two three four five six' ]] 44*4887Schinthen err_exit 'index array append fails' 45*4887Schinfi 46*4887Schinunset iarray 47*4887Schiniarray=one 48*4887Schin{ iarray+= (four five six) ;} 2> /dev/null 49*4887Schinif [[ ${iarray[@]} != 'one four five six' ]] 50*4887Schinthen err_exit 'index array append to scalar fails' 51*4887Schinfi 52*4887Schintypeset -A aarray 53*4887Schinaarray=( [1]=1 [3]=4 [xyz]=xyz ) 54*4887Schinaarray+=( [2]=2 [3]=3 [foo]=bar ) 55*4887Schinif [[ ${aarray[3]} != 3 ]] 56*4887Schinthen err_exit 'associative array append fails' 57*4887Schinfi 58*4887Schinif [[ ${#aarray[@]} != 5 ]] 59*4887Schinthen err_exit 'number of elements of associative array append fails' 60*4887Schinfi 61*4887Schinpoint=(x=1 y=2) 62*4887Schinpoint+=( y=3 z=4) 63*4887Schinif [[ ${point.y} != 3 ]] 64*4887Schinthen err_exit 'compound append fails' 65*4887Schinfi 66*4887Schinunset foo 67*4887Schinfoo=one 68*4887Schinfoo+=(two) 69*4887Schinif [[ ${foo[@]} != 'one two' ]] 70*4887Schinthen err_exit 'array append to non array variable fails' 71*4887Schinfi 72*4887Schinexit $((Errors)) 73