xref: /titanic_50/usr/src/lib/libshell/common/tests/functions.sh (revision b5d3ab78446c645a1150b57b7a58b535229ee742)
1########################################################################
2#                                                                      #
3#               This software is part of the ast package               #
4#           Copyright (c) 1982-2007 AT&T Knowledge Ventures            #
5#                      and is licensed under the                       #
6#                  Common Public License, Version 1.0                  #
7#                      by AT&T Knowledge Ventures                      #
8#                                                                      #
9#                A copy of the License is available at                 #
10#            http://www.opensource.org/licenses/cpl1.0.txt             #
11#         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         #
12#                                                                      #
13#              Information and Software Systems Research               #
14#                            AT&T Research                             #
15#                           Florham Park NJ                            #
16#                                                                      #
17#                  David Korn <dgk@research.att.com>                   #
18#                                                                      #
19########################################################################
20function err_exit
21{
22	print -u2 -n "\t"
23	print -u2 -r ${Command}[$1]: "${@:2}"
24	let Errors+=1
25}
26alias err_exit='err_exit $LINENO'
27
28integer Errors=0
29Command=${0##*/}
30integer foo=33
31bar=bye
32# check for global variables and $0
33function foobar
34{
35	case $1 in
36	1) 	print -r - "$foo" "$bar";;
37	2)	print -r - "$0";;
38	3)	typeset foo=foo
39		integer bar=10
40	 	print -r - "$foo" "$bar";;
41	4)	trap 'foo=36' EXIT
42		typeset foo=20;;
43	esac
44}
45function print
46{
47	command print hi
48}
49if	[[ $(print) != hi ]]
50then	err_exit "command print not working inside print function"
51fi
52unset -f print
53
54if	[[ $(foobar 1) != '33 bye' ]]
55then	err_exit 'global variables not correct'
56fi
57
58if	[[ $(foobar 2) != 'foobar' ]]
59then	err_exit '$0  not correct'
60fi
61
62if	[[ $(bar=foo foobar 1) != '33 foo' ]]
63then	err_exit 'environment override not correct'
64fi
65if	[[ $bar == foo ]]
66then	err_exit 'scoping error'
67fi
68
69if	[[ $(foobar 3) != 'foo 10' ]]
70then	err_exit non-local variables
71fi
72
73foobar 4
74if	[[ $foo != 36 ]]
75then	err_exit EXIT trap in wrong scope
76fi
77unset -f foobar || err_exit "cannot unset function foobar"
78typeset -f foobar>/dev/null  && err_exit "typeset -f has incorrect exit status"
79
80function foobar
81{
82	(return 0)
83}
84> /tmp/shtests$$.1
85{
86foobar
87if	[ -r /tmp/shtests$$.1 ]
88then	rm -r /tmp/shtests$$.1
89else	err_exit 'return within subshell inside function error'
90fi
91}
92abc() print hi
93if	[[ $(abc) != hi ]]
94then	err_exit 'abc() print hi not working'
95fi
96( unset -f abc )
97if	[[ $(abc 2>/dev/null) != hi ]]
98then	err_exit 'abc() print hi not working after subshell unset'
99fi
100(
101	function f
102	{
103		exit 1
104	}
105	f
106	err_exit 'exit from function not working'
107)
108unset -f foo
109function foo
110{
111	x=2
112	(
113		x=3
114		cd /tmp
115		print bar
116	)
117	if	[[ $x != 2 ]]
118	then	err_exit 'value of x not restored after subshell inside function'
119	fi
120}
121x=1
122dir=$PWD
123if	[[ $(foo) != bar ]]
124then	err_exit 'cd inside nested subshell not working'
125fi
126if	[[ $PWD != "$dir" ]]
127then	err_exit 'cd inside nested subshell changes $PWD'
128fi
129fun() /bin/echo hello
130if	[[ $(fun) != hello ]]
131then	err_exit one line functions not working
132fi
133trap 'rm -f /tmp/script$$ /tmp/data$$.[12]' EXIT
134cat > /tmp/script$$ <<-\!
135	print -r -- "$1"
136!
137chmod +x /tmp/script$$
138function passargs
139{
140	/tmp/script$$ "$@"
141}
142if	[[ $(passargs one) != one ]]
143then	err_exit 'passing args from functions to scripts not working'
144fi
145cat > /tmp/script$$ <<-\!
146	trap 'exit 0' EXIT
147	function foo
148	{
149		/tmp > /dev/null  2>&1
150	}
151	foo
152!
153if	! /tmp/script$$
154then	err_exit 'exit trap incorrectly triggered'
155fi
156if	! $SHELL -c /tmp/script$$
157then	err_exit 'exit trap incorrectly triggered when invoked with -c'
158fi
159$SHELL -c "trap 'rm /tmp/script$$' EXIT"
160if	[[ -f /tmp/script$$ ]]
161then	err_exit 'exit trap not triggered when invoked with -c'
162fi
163cat > /tmp/script$$ <<- \EOF
164	foobar()
165	{
166		return
167	}
168	shift
169	foobar
170	print -r -- "$1"
171EOF
172chmod +x /tmp/script$$
173if	[[ $( $SHELL /tmp/script$$ arg1 arg2) != arg2 ]]
174then	err_exit 'arguments not restored by posix functions'
175fi
176function foo
177{
178	print hello
179}
180(
181	function foo
182	{
183		print bar
184	}
185	if [[ $(foo) != bar ]]
186	then	err_exit 'function definitions inside subshells not working'
187	fi
188)
189if [[ $(foo) != hello ]]
190then	err_exit 'function definitions inside subshells not restored'
191fi
192unset -f foo bar
193function bar
194{
195        print "$y"
196}
197
198function foo
199{
200        typeset x=3
201        y=$x bar
202}
203x=1
204if	[[ $(foo) != 3 ]]
205then	err_exit 'variable assignment list not using parent scope'
206fi
207unset -f foo$$
208trap "rm -f /tmp/foo$$" EXIT INT
209cat > /tmp/foo$$ <<!
210function foo$$
211{
212	print foo
213}
214!
215chmod +x /tmp/foo$$
216FPATH=/tmp
217autoload foo$$
218if	[[ $(foo$$ 2>/dev/null) != foo ]]
219then	err_exit 'autoload not working'
220fi
221unset -f foobar
222function foobar
223{
224	typeset -r x=3
225	return 0
226}
227( foobar ) 2> /dev/null || err_exit "cannot unset readonly variable in function"
228if	$SHELL -n 2> /dev/null <<-!
229	abc()
230	!
231then	err_exit 'abc() without a function body is not a syntax error'
232fi
233function winpath
234{
235	usage='q pathname ...'
236	typeset var format=s
237	while   getopts  "$usage" var
238	do      case $var in
239		q)      format=q;;
240	        esac
241	done
242	print done
243}
244if	[[ $( (winpath --man 2>/dev/null); print ok) != ok ]]
245then	err_exit 'getopts --man in functions not working'
246fi
247if	[[ $( (winpath -z 2>/dev/null); print ok) != ok ]]
248then	err_exit 'getopts with bad option in functions not working'
249fi
250unset -f x
251function x
252{
253        print "$@"
254}
255typeset -ft x
256if      [[ $(x x=y 2>/dev/null) != x=y ]]
257then    err_exit 'name=value pair args not passed to traced functions'
258fi
259function bad
260{
261	false
262}
263trap 'val=false' ERR
264val=true
265bad
266if	[[ $val != false ]]
267then	err_exit 'set -e not working for functions'
268fi
269function bad
270{
271	false
272	return 0
273}
274val=true
275bad
276if	[[ $val != true ]]
277then	err_exit 'set -e not disabled for functions'
278fi
279bad()
280{
281	false
282	return 0
283}
284val=true
285bad
286if	[[ $val != false ]]
287then	err_exit 'set -e not inherited for posix functions'
288fi
289function myexport
290{
291	nameref var=$1
292	if	(( $# > 1 ))
293	then	export	$1=$2
294	fi
295	if	(( $# > 2 ))
296	then	print $(myexport "$1" "$3" )
297		return
298	fi
299	typeset val
300	val=$(export | grep "^$1=")
301	print ${val#"$1="}
302
303}
304export dgk=base
305if	[[ $(myexport dgk fun) != fun ]]
306then	err_exit 'export inside function not working'
307fi
308val=$(export | grep "^dgk=")
309if	[[ ${val#dgk=} != base ]]
310then	err_exit 'export not restored after function call'
311fi
312if	[[ $(myexport dgk fun fun2) != fun2 ]]
313then	err_exit 'export inside function not working with recursive function'
314fi
315val=$(export | grep "^dgk=")
316if	[[ ${val#dgk=} != base ]]
317then	err_exit 'export not restored after recursive function call'
318fi
319if	[[ $(dgk=try3 myexport dgk) != try3 ]]
320then	err_exit 'name=value not added to export list with function call'
321fi
322val=$(export | grep "^dgk=")
323if	[[ ${val#dgk=} != base ]]
324then	err_exit 'export not restored name=value function call'
325fi
326unset zzz
327if	[[ $(myexport zzz fun) != fun ]]
328then	err_exit 'export inside function not working for zzz'
329fi
330if	[[ $(export | grep "zzz=") ]]
331then	err_exit 'zzz exported after function call'
332fi
333unset zzz
334typeset -u zzz
335function foo
336{
337	zzz=abc
338	print $zzz
339}
340if	[[ $(foo)$(foo) != ABCABC ]]
341then	err_exit 'attributes on unset variables not saved/restored'
342fi
343function xpd {
344	typeset i j=$1
345                for i
346                        do print i=$i j=$j
347                        [[ $i == a ]] && xpd b
348                        done
349                }
350if	[[ $(xpd a c) != $'i=a j=a\ni=b j=b\ni=c j=a' ]]
351then	err_exit 'for loop function optimization error'
352fi
353
354typeset -A visited
355integer level=0
356function closure
357{
358	(( $# > 5 )) && return 1
359	((level < 2)) && ((level++))
360	typeset tmp r=0
361	visited[$1]=1
362
363	for tmp in $level _$level
364	do
365		[[ ${visited[$tmp]} == 1 ]] && continue
366		closure $tmp $* || r=1
367	done
368	return $r
369}
370closure 0 || err_exit -u2 'for loop function optimization bug2'
371mkdir  /tmp/ksh$$ || err_exit "mkdir /tmp/ksh$$ failed"
372cd /tmp/ksh$$ || err_exit "cd /tmp/ksh$$ failed"
373print 'false' > try
374chmod +x try
375cat > tst <<- EOF
376	function ignore
377	{
378		./try
379		return 0
380	}
381	trap "print error; exit 1" ERR
382	ignore
383EOF
384if	[[ $($SHELL < tst)  == error ]]
385then	err_exit 'ERR trap not cleared'
386fi
387FPATH=/tmp/ksh$$
388print ': This does nothing' > /tmp/ksh$$/foobar
389chmod +x /tmp/ksh$$/foobar
390unset -f  foobar
391{ foobar;} 2> /dev/null
392if	[[ $? != 126 ]]
393then	err_exit 'function file without function definition processes wrong error'
394fi
395print 'set a b c' > dotscript
396[[ $(PATH=$PATH: $SHELL -c '. dotscript;print $#') == 3 ]] || err_exit 'positional parameters not preserved with . script without arguments'
397cd ~- || err_exit "cd back failed"
398cd /; rm -r /tmp/ksh$$ || err_exit "rm -r /tmp/ksh$$ failed"
399function errcheck
400{
401	trap 'print ERR; return 1' ERR
402	false
403	print ok
404}
405err=$(errcheck)
406[[ $err == ERR ]] || err_exit 'trap on ERR not working in a function'
407x="$(
408	function foobar
409	{
410		print ok
411	}
412	typeset -f foobar
413)"
414eval "$x"  || err_exit 'typeset -f generates syntax error'
415[[ $(foobar) != ok ]] && err_exit 'typeset -f not generating function'
416unset -f a b c
417a()
418{
419        b
420        b
421        print ${.sh.fun}
422}
423b() { : ;}
424[[ $(a) == a ]] || err_exit '.sh.fun not set correctly in a function'
425print $'a(){\ndate\n}'  | $SHELL 2> /dev/null || err_exit 'parser error in a(){;date;}'
426cat > /tmp/data$$.1 << '++EOF'
427     1  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
428     2  XXXXXXXXXXXXXXXXX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717cmp -s /tmp/data$$.[12] || err_exit 'error with long functions'
718rm -f /tmp/script$$ /tmp/data$$.[12]
719v=1
720function f
721{
722	typeset i
723	for i in 0 1
724	do	typeset v
725		v=$i
726		[[ $v == $i ]] || return 1
727	done
728}
729f || err_exit "typeset optimization bug"
730function f
731{
732	print -r -- "$foo$bar"
733}
734function g
735{
736	print -r -- $(bar=bam f)
737}
738unset foo bar
739[[ $(foo=hello g) == hellobam ]] || err_exit 'function exports not passed on'
740[[ $(bar=hello g) == bam ]] || err_exit 'function exports not overridden'
741unset -f foo
742function foo
743{
744	typeset line=$1
745	set +n
746	while	[[ $line ]]
747	do	if	[[ ! $varname ]]
748		then	varname=${line%% *}
749			line=${line##"$varname"?( )}
750			[[ $line ]] && continue
751		else	print ok
752			return
753		fi
754		varname=
755	done
756}
757[[ $(foo 'NUMBERED RECORDSIZE') == ok ]] || err_exit 'optimization error with undefined variable'
758exit $((Errors))
759