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*4887Schinalias foo='print hello' 31*4887Schinif [[ $(foo) != hello ]] 32*4887Schinthen err_exit 'foo, where foo is alias for "print hello" failed' 33*4887Schinfi 34*4887Schinif [[ $(foo world) != 'hello world' ]] 35*4887Schinthen err_exit 'foo world, where foo is alias for "print hello" failed' 36*4887Schinfi 37*4887Schinalias foo='print hello ' 38*4887Schinalias bar=world 39*4887Schinif [[ $(foo bar) != 'hello world' ]] 40*4887Schinthen err_exit 'foo bar, where foo is alias for "print hello " failed' 41*4887Schinfi 42*4887Schinif [[ $(foo \bar) != 'hello bar' ]] 43*4887Schinthen err_exit 'foo \bar, where foo is alias for "print hello " failed' 44*4887Schinfi 45*4887Schinalias bar='foo world' 46*4887Schinif [[ $(bar) != 'hello world' ]] 47*4887Schinthen err_exit 'bar, where bar is alias for "foo world" failed' 48*4887Schinfi 49*4887Schinif [[ $(alias bar) != "bar='foo world'" ]] 50*4887Schinthen err_exit 'alias bar, where bar is alias for "foo world" failed' 51*4887Schinfi 52*4887Schinunalias foo || err_exit "unalias foo failed" 53*4887Schinalias foo 2> /dev/null && err_exit "alias for non-existent alias foo returns true" 54*4887Schinunset bar 55*4887Schinalias bar="print foo$bar" 56*4887Schinbar=bar 57*4887Schinif [[ $(bar) != foo ]] 58*4887Schinthen err_exit 'alias bar, where bar is alias for "print foo$bar" failed' 59*4887Schinfi 60*4887Schinunset bar 61*4887Schinalias bar='print hello' 62*4887Schinif [[ $bar != '' ]] 63*4887Schinthen err_exit 'alias bar cause variable bar to be set' 64*4887Schinfi 65*4887Schinalias !!=print 66*4887Schinif [[ $(!! hello 2>/dev/null) != hello ]] 67*4887Schinthen err_exit 'alias for !!=print not working' 68*4887Schinfi 69*4887Schinalias foo=echo 70*4887Schinif [[ $(print "$(foo bar)" ) != bar ]] 71*4887Schinthen err_exit 'alias in command substitution not working' 72*4887Schinfi 73*4887Schin( unalias foo) 74*4887Schinif [[ $(foo bar 2> /dev/null) != bar ]] 75*4887Schinthen err_exit 'alias not working after unalias in subshell' 76*4887Schinfi 77*4887Schinbuiltin -d rm 2> /dev/null 78*4887Schinif whence rm > /dev/null 79*4887Schinthen [[ ! $(alias -t | grep rm= ) ]] && err_exit 'tracked alias not set' 80*4887Schin PATH=$PATH 81*4887Schin [[ $(alias -t | grep rm= ) ]] && err_exit 'tracked alias not cleared' 82*4887Schinfi 83*4887Schinexit $((Errors)) 84