xref: /openbsd/regress/bin/ksh/regress.t (revision 264ca280)
1#	$OpenBSD: regress.t,v 1.2 2015/07/30 17:24:08 millert Exp $
2
3#
4# The first 39 of these tests are from the old Bugs script.
5#
6
7name: regression-1
8description:
9	Lex array code had problems with this.
10stdin:
11	echo foo[
12	n=bar
13	echo "hi[ $n ]=1"
14expected-stdout:
15	foo[
16	hi[ bar ]=1
17---
18
19
20name: regression-2
21description:
22	When PATH is set before running a command, the new path is
23	not used in doing the path search
24		$ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
25		$ PATH=/tmp q
26		q: not found
27		$
28	in comexec() the two lines
29		while (*vp != NULL)
30			(void) typeset(*vp++, xxx, 0);
31	need to be moved out of the switch to before findcom() is
32	called - I don't know what this will break.
33stdin:
34	: ${PWD:-`pwd 2> /dev/null`}
35	: ${PWD:?"PWD not set - can't do test"}
36	mkdir Y
37	cat > Y/xxxscript << EOF
38	#!/bin/sh
39	# Need to restore path so echo can be found (some shells don't have
40	# it as a built-in)
41	PATH=\$OLDPATH
42	echo hi
43	exit 0
44	EOF
45	chmod a+rx Y/xxxscript
46	export OLDPATH="$PATH"
47	PATH=$PWD/Y xxxscript
48	exit $?
49expected-stdout:
50	hi
51---
52
53
54#
55#   3. Sun OS 4.0.x (This seems to be a problem with sun's PENDIN not being done
56#      properly)
57#   	sleep 5^J ls^J ls^J ls		[only first ls runs]
58#   	vi ... ZZ (while waiting type)	[some of the input gets eaten]
59#      [not present in SunOS 4.1.x]
60#echo "  [No automatic test for bug 3 - interactive]"
61
62
63#
64#   4. (fixed)
65#
66#echo "  [Don't know what bug 4 was]"
67
68
69#
70#   5. Everywhere
71#   	File name completion (^X,*) does not mesh well with cd and
72#   	symbolic links.  cd does path simplification wrt $PWD before
73#   	doing the actual chdir(), while file name completion does
74#   	not do the simplification. E.g., you are in directory A
75#   	which has a symbolic link to directory B, you create a file
76#   	called foobar and you then cd to the symlink to B, and type
77#   		$ echo ../foo^X
78#   	and the shell beeps at you.  Would be more consistent to
79#   	do the completion after simplifing the `$PWD/..'.
80#echo "  [No automatic test for bug 5 - interactive]"
81
82
83name: regression-6
84description:
85	Parsing of $(..) expressions is non-optimal.  It is
86	impossible to have any parentheses inside the expression.
87	I.e.,
88		$ ksh -c 'echo $(echo \( )'
89		no closing quote
90		$ ksh -c 'echo $(echo "(" )'
91		no closing quote
92		$
93	The solution is to hack the parsing clode in lex.c, the
94	question is how to hack it: should any parentheses be
95	escaped by a backslash, or should recursive parsing be done
96	(so quotes could also be used to hide hem).  The former is
97	easier, the later better...
98stdin:
99	echo $(echo \()
100expected-stdout:
101	(
102---
103
104
105#
106#   7. (fixed)
107#
108#echo "  [Don't know what bug 7 was]"
109
110
111#
112#   8. Everywhere - NOT A BUG - this is what at&t ksh88 does
113#   	Strange typset -x behaviour in functions.  The following function
114#   	does not set the environment variable BLAH outside the function:
115#   		function blah
116#   		{
117#   			typeset -x BLAH=foobar
118#   		}
119#   	This function does work:
120#   		function blah
121#   		{ BLAH=foobar; export BLAH
122#   		}
123#echo '  [Bug 8 was bogus]'
124
125
126name: regression-9
127description:
128	Continue in a for loop does not work right:
129		for i in a b c ; do
130			if [ $i = b ] ; then
131				continue
132			fi
133			echo $i
134		done
135	Prints a forever...
136stdin:
137	first=yes
138	for i in a b c ; do
139		if [ $i = b ] ; then
140			if [ $first = no ] ; then
141				echo 'continue in for loop broken'
142				break	# hope break isn't broken too :-)
143			fi
144			first=no
145			continue
146		fi
147	done
148	echo bye
149expected-stdout:
150	bye
151---
152
153
154name: regression-10
155description:
156	The following:
157		set -- `false`
158		echo $?
159	shoud not print 0. (according to /bin/sh, at&t ksh88, and the
160	getopt(1) man page - not according to POSIX)
161stdin:
162	set -- `false`
163	echo $?
164expected-stdout:
165	1
166---
167
168
169name: regression-11
170description:
171	The following:
172		x=/foo/bar/blah
173		echo ${x##*/}
174	should echo blah but on some machines echos /foo/bar/blah.
175stdin:
176	x=/foo/bar/blah
177	echo ${x##*/}
178expected-stdout:
179	blah
180---
181
182
183name: regression-12
184description:
185	Both of the following echos produce the same output under sh/ksh.att:
186		#!/bin/sh
187		x="foo	bar"
188		echo "`echo \"$x\"`"
189		echo "`echo "$x"`"
190	pdksh produces different output for the former (foo instead of foo\tbar)
191stdin:
192	x="foo	bar"
193	echo "`echo \"$x\"`"
194	echo "`echo "$x"`"
195expected-stdout:
196	foo	bar
197	foo	bar
198---
199
200
201name: regression-13
202description:
203	The following command hangs forever:
204		$ (: ; cat /etc/termcap) | sleep 2
205	This is because the shell forks a shell to run the (..) command
206	and this shell has the pipe open.  When the sleep dies, the cat
207	doesn't get a SIGPIPE 'cause a process (ie, the second shell)
208	still has the pipe open.
209
210	NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
211	      commands from /etc/termcap..)
212time-limit: 10
213stdin:
214	echo A line of text that will be duplicated quite a number of times.> t1
215	cat t1 t1 t1 t1  t1 t1 t1 t1  t1 t1 t1 t1  t1 t1 t1 t1  > t2
216	cat t2 t2 t2 t2  t2 t2 t2 t2  t2 t2 t2 t2  t2 t2 t2 t2  > t1
217	cat t1 t1 t1 t1 > t2
218	(: ; cat t2) | sleep 1
219---
220
221
222name: regression-14
223description:
224	The command
225		$ (foobar) 2> /dev/null
226	generates no output under /bin/sh, but pdksh produces the error
227		foobar: not found
228	Also, the command
229		$ foobar 2> /dev/null
230	generates an error under /bin/sh and pdksh, but at&t ksh88 produces
231	no error (redirected to /dev/null).
232stdin:
233	(you/should/not/see/this/error/1) 2> /dev/null
234	you/should/not/see/this/error/2 2> /dev/null
235	true
236---
237
238
239name: regression-15
240description:
241	The command
242		$ whence foobar
243	generates a blank line under pdksh and sets the exit status to 0.
244	at&t ksh88 generates no output and sets the exit status to 1.  Also,
245	the command
246		$ whence foobar cat
247	generates no output under at&t ksh88 (pdksh generates a blank line
248	and /bin/cat).
249stdin:
250	whence does/not/exist > /dev/null
251	echo 1: $?
252	echo 2: $(whence does/not/exist | wc -l)
253	echo 3: $(whence does/not/exist cat | wc -l)
254expected-stdout:
255	1: 1
256	2: 0
257	3: 0
258---
259
260
261name: regression-16
262description:
263	${var%%expr} seems to be broken in many places.  On the mips
264	the commands
265		$ read line < /etc/passwd
266		$ echo $line
267		root:0:1:...
268		$ echo ${line%%:*}
269		root
270		$ echo $line
271		root
272		$
273	change the value of line.  On sun4s & pas, the echo ${line%%:*} doesn't
274	work.  Haven't checked elsewhere...
275script:
276	read x
277	y=$x
278	echo ${x%%:*}
279	echo $x
280stdin:
281	root:asdjhasdasjhs:0:1:Root:/:/bin/sh
282expected-stdout:
283	root
284	root:asdjhasdasjhs:0:1:Root:/:/bin/sh
285---
286
287
288name: regression-17
289description:
290	The command
291		. /foo/bar
292	should set the exit status to non-zero (sh and at&t ksh88 do).
293	XXX doting a non existent file is a fatal error for a script
294stdin:
295	. does/not/exist
296expected-exit: e != 0
297expected-stderr-pattern: /.?/
298---
299
300
301#
302#   18. Everywhere
303#   	In vi mode ^X (and *) can dump core:
304#   		$ ab[cd^XMemory fault (core dumped)
305#echo "  [No automatic test for bug 18 - interactive]"
306
307
308name: regression-19
309description:
310	Both of the following echos should produce the same thing, but don't:
311		$ x=foo/bar
312		$ echo ${x%/*}
313		foo
314		$ echo "${x%/*}"
315		foo/bar
316stdin:
317	x=foo/bar
318	echo "${x%/*}"
319expected-stdout:
320	foo
321---
322
323
324#
325#   20. (same as 18)
326#
327
328
329name: regression-21
330description:
331	backslash does not work as expected in case labels:
332	$ x='-x'
333	$ case $x in
334	-\?) echo hi
335	esac
336	hi
337	$ x='-?'
338	$ case $x in
339	-\\?) echo hi
340	esac
341	hi
342	$
343stdin:
344	case -x in
345	-\?)	echo fail
346	esac
347---
348
349
350name: regression-22
351description:
352	Quoting backquotes inside backquotes doesn't work:
353	$ echo `echo hi \`echo there\` folks`
354	asks for more info.  sh and at&t ksh88 both echo
355	hi there folks
356stdin:
357	echo `echo hi \`echo there\` folks`
358expected-stdout:
359	hi there folks
360---
361
362
363name: regression-23
364description:
365	)) is not treated `correctly':
366	    $ (echo hi ; (echo there ; echo folks))
367	    missing ((
368	    $
369	instead of (as sh and ksh.att)
370	    $ (echo hi ; (echo there ; echo folks))
371	    hi
372	    there
373	    folks
374	    $
375stdin:
376	( : ; ( : ; echo hi))
377expected-stdout:
378	hi
379---
380
381
382#
383#   24. strangeness with file name completion involving symlinks to nowhere
384#   	$ mkdir foo foo/bar
385#   	$ ln -s /stuff/junk foo/bar/xx
386#   	$ echo foo/*/xx 
387#	(beep)
388#   	$
389#echo "  [No automatic test for bug 24 - interactive]"
390
391
392name: regression-25
393description:
394	Check reading stdin in a while loop.  The read should only read
395	a single line, not a whole stdio buffer; the cat should get
396	the rest.
397stdin:
398	(echo a; echo b) | while read x ; do
399	    echo $x
400	    cat > /dev/null
401	done
402expected-stdout:
403	a
404---
405
406
407name: regression-26
408description:
409	Check reading stdin in a while loop.  The read should read both
410	lines, not just the first.
411script:
412	a=
413	while [ "$a" != xxx ] ; do
414	    last=$x
415	    read x
416	    cat /dev/null | sed 's/x/y/'
417	    a=x$a
418	done
419	echo $last
420stdin:
421	a
422	b
423expected-stdout:
424	b
425---
426
427
428name: regression-27
429description:
430	The command
431		. /does/not/exist
432	should cause a script to exit.
433stdin:
434	. does/not/exist
435	echo hi
436expected-exit: e != 0
437expected-stderr-pattern: /does\/not\/exist/
438---
439
440
441name: regression-28
442description:
443	variable assignements not detected well
444stdin:
445	a.x=1 echo hi
446expected-exit: e != 0
447expected-stderr-pattern: /a\.x=1/
448---
449
450
451name: regression-29
452description:
453	alias expansion different from at&t ksh88
454stdin:
455	alias a='for ' b='i in'
456	a b hi ; do echo $i ; done
457expected-stdout:
458	hi
459---
460
461
462name: regression-30
463description:
464	strange characters allowed inside ${...}
465stdin:
466	echo ${a{b}}
467expected-exit: e != 0
468expected-stderr-pattern: /.?/
469---
470
471
472name: regression-31
473description:
474	Does read handle partial lines correctly
475script:
476	a= ret=
477	while [ "$a" != xxx ] ; do
478	    read x y z
479	    ret=$?
480	    a=x$a
481	done
482	echo "[$x]"
483	echo $ret
484stdin: !
485	a A aA
486	b B Bb
487	c
488expected-stdout:
489	[c]
490	1
491---
492
493
494name: regression-32
495description:
496	Does read set variables to null at eof?
497script:
498	a=
499	while [ "$a" != xxx ] ; do
500	    read x y z
501	    a=x$a
502	done
503	echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
504	echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
505stdin:
506	a A Aa
507	b B Bb
508expected-stdout:
509	1:
510	2:
511---
512
513
514name: regression-33
515description:
516	Does umask print a leading 0 when umask is 3 digits?
517stdin:
518	umask 222
519	umask
520expected-stdout:
521	0222
522---
523
524
525#
526#
527#	Does umask print a umask of 0 sanely?
528#	There is lots of variety here (0, 00, 000, and 0000 have all been
529#	seen in various shells...)
530#
531#echo '  [Bug 34 was bogus]'
532
533
534name: regression-35
535description:
536	Tempory files used for here-docs in functions get trashed after
537	the function is parsed (before it is executed)
538stdin:
539	f1() {
540		cat <<- EOF
541			F1
542		EOF
543		f2() {
544			cat <<- EOF
545				F2
546			EOF
547		}
548	}
549	f1
550	f2
551	unset -f f1
552	f2
553expected-stdout:
554	F1
555	F2
556	F2
557---
558
559
560name: regression-36
561description:
562	Command substitution breaks reading in while loop
563	(test from <sjg@void.zen.oz.au>)
564stdin:
565	(echo abcdef; echo; echo 123) |
566	    while read line
567	    do
568	      # the following line breaks it
569	      c=`echo $line | wc -c`
570	      echo $c
571	    done
572expected-stdout:
573	7
574	1
575	4
576---
577
578
579name: regression-37
580description:
581	Machines with broken times() (reported by <sjg@void.zen.oz.au>)
582	time does not report correct real time
583stdin:
584	time sleep 1
585expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
586---
587
588
589name: regression-38
590description:
591	set -e doesn't ignore exit codes for if/while/until/&&/||/!.
592arguments: !-e!
593stdin:
594	if false; then echo hi ; fi
595	false || true
596	false && true
597	while false; do echo hi; done
598	echo ok
599expected-stdout:
600	ok
601---
602
603name: regression-39
604description:
605	set -e: errors in command substitutions aren't ignored
606arguments: !-e!
607stdin:
608	echo `false; echo hi` $(< this-file-does-not-exist)
609expected-stdout:
610
611expected-stderr-pattern: /this-file-does-not-exist/
612---
613
614name: regression-40
615description:
616	This used to cause a core dump
617env-setup: !RANDOM=12!
618stdin:
619	echo hi
620expected-stdout:
621	hi
622---
623
624name: regression-41
625description:
626	foo should be set to bar (should not be empty)
627stdin:
628	foo=`
629	echo bar`
630	echo "($foo)"
631expected-stdout:
632	(bar)
633---
634
635name: regression-42
636description:
637	Can't use command line assignments to assign readonly parameters.
638stdin:
639	foo=bar
640	readonly foo
641	foo=stuff env | grep '^foo'
642expected-exit: e != 0
643expected-stderr-pattern:
644	/.*read *only.*/
645---
646
647name: regression-43
648description:
649	Can subshells be prefixed by redirections (historical shells allow
650	this)
651stdin:
652	< /dev/null (sed 's/^/X/')
653---
654
655name: regression-44
656description:
657	getopts sets OPTIND correctly for unparsed option
658stdin:
659	set -- -a -a -x
660	while getopts :a optc; do
661	    echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
662	done
663	echo done
664expected-stdout:
665	OPTARG=, OPTIND=2, optc=a.
666	OPTARG=, OPTIND=3, optc=a.
667	OPTARG=x, OPTIND=3, optc=?.
668	done
669---
670
671name: regression-45
672description:
673	Parameter assignments with [] recognized correctly
674stdin:
675	FOO=*[12]
676	BAR=abc[
677	MORE=[abc]
678	JUNK=a[bc
679	echo "<$FOO>"
680	echo "<$BAR>"
681	echo "<$MORE>"
682	echo "<$JUNK>"
683expected-stdout:
684	<*[12]>
685	<abc[>
686	<[abc]>
687	<a[bc>
688---
689
690name: regression-46
691description:
692	Check that alias expansion works in command substitutions and
693	at the end of file.
694stdin:
695	alias x='echo hi'
696	FOO="`x` "
697	echo "[$FOO]"
698	x
699expected-stdout:
700	[hi ]
701	hi
702---
703
704name: regression-47
705description:
706	Check that aliases are fully read.
707stdin:
708	alias x='echo hi;
709	echo there'
710	x
711	echo done
712expected-stdout:
713	hi
714	there
715	done
716---
717
718name: regression-48
719description:
720	Check that (here doc) temp files are not left behind after an exec.
721stdin:
722	mkdir foo || exit 1
723	TMPDIR=$PWD/foo $0 <<- 'EOF'
724		x() {
725			sed 's/^/X /' << E_O_F
726			hi
727			there
728			folks
729			E_O_F
730			echo "done ($?)"
731		}
732		echo=echo; [ -x /bin/echo ] && echo=/bin/echo
733		exec $echo subtest-1 hi
734	EOF
735	echo subtest-1 foo/*
736	TMPDIR=$PWD/foo $0 <<- 'EOF'
737		echo=echo; [ -x /bin/echo ] && echo=/bin/echo
738		sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
739		a
740		few
741		lines
742		E_O_F
743	EOF
744	echo subtest-2 foo/*
745expected-stdout:
746	subtest-1 hi
747	subtest-1 foo/*
748	X a
749	X few
750	X lines
751	subtest-2 hi
752	subtest-2 foo/*
753---
754
755name: regression-49
756description:
757	Check that unset params with attributes are reported by set, those
758	sans attributes are not.
759stdin:
760	unset FOO BAR
761	echo X$FOO
762	export BAR
763	typeset -i BLAH
764	set | grep FOO
765	set | grep BAR
766	set | grep BLAH
767expected-stdout:
768	X
769	BAR
770	BLAH
771---
772
773name: regression-50
774description:
775	Check that aliases do not use continuation prompt after trailing
776	semi-colon.
777file-setup: file 644 "env"
778	PS1=Y
779	PS2=X
780env-setup: !ENV=./env!
781arguments: !-i!
782stdin:
783	alias foo='echo hi ; '
784	foo
785	foo echo there
786expected-stdout:
787	hi
788	hi
789	there
790expected-stderr: !
791	YYYY
792---
793
794name: regression-51
795description:
796	Check that set allows both +o and -o options on same command line.
797stdin:
798	set a b c
799	set -o noglob +o allexport
800	echo A: $*, *
801expected-stdout:
802	A: a b c, *
803---
804
805name: regression-52
806description:
807	Check that globing works in pipelined commands
808file-setup: file 644 "env"
809	PS1=P
810file-setup: file 644 "abc"
811	stuff
812env-setup: !ENV=./env!
813arguments: !-i!
814stdin:
815	sed 's/^/X /' < ab*
816	echo mark 1
817	sed 's/^/X /' < ab* | sed 's/^/Y /'
818	echo mark 2
819expected-stdout:
820	X stuff
821	mark 1
822	Y X stuff
823	mark 2
824expected-stderr: !
825	PPPPP
826---
827
828name: regression-53
829description:
830	Check that getopts works in functions
831stdin:
832	#!/bin/ksh
833
834	bfunc() {
835	    echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
836	    while getopts B oc; do
837		case $oc in
838		  (B)
839		    echo bfunc: B option
840		    ;;
841		  (*)
842		    echo bfunc: odd option "($oc)"
843		    ;;
844		esac
845	    done
846	    echo bfunc: leave
847	}
848
849	function kfunc {
850	    echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
851	    while getopts K oc; do
852		case $oc in
853		  (K)
854		    echo kfunc: K option
855		    ;;
856		  (*)
857		    echo bfunc: odd option "($oc)"
858		    ;;
859		esac
860	    done
861	    echo kfunc: leave
862	}
863
864	set -- -f -b -k -l
865	echo "line 1: OPTIND=$OPTIND"
866	getopts kbfl optc
867	echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
868	bfunc -BBB blah
869	echo "line 3: OPTIND=$OPTIND"
870	getopts kbfl optc
871	echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
872	kfunc -KKK blah
873	echo "line 5: OPTIND=$OPTIND"
874	getopts kbfl optc
875	echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
876	echo
877
878	OPTIND=1
879	set -- -fbkl
880	echo "line 10: OPTIND=$OPTIND"
881	getopts kbfl optc
882	echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
883	bfunc -BBB blah
884	echo "line 30: OPTIND=$OPTIND"
885	getopts kbfl optc
886	echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
887	kfunc -KKK blah
888	echo "line 50: OPTIND=$OPTIND"
889	getopts kbfl optc
890	echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
891expected-stdout:
892	line 1: OPTIND=1
893	line 2: ret=0, optc=f, OPTIND=2
894	bfunc: enter (args: -BBB blah; OPTIND=2)
895	bfunc: B option
896	bfunc: B option
897	bfunc: leave
898	line 3: OPTIND=2
899	line 4: ret=0, optc=b, OPTIND=3
900	kfunc: enter (args: -KKK blah; OPTIND=1)
901	kfunc: K option
902	kfunc: K option
903	kfunc: K option
904	kfunc: leave
905	line 5: OPTIND=3
906	line 6: ret=0, optc=k, OPTIND=4
907
908	line 10: OPTIND=1
909	line 20: ret=0, optc=f, OPTIND=2
910	bfunc: enter (args: -BBB blah; OPTIND=2)
911	bfunc: B option
912	bfunc: B option
913	bfunc: leave
914	line 30: OPTIND=2
915	line 40: ret=1, optc=?, OPTIND=2
916	kfunc: enter (args: -KKK blah; OPTIND=1)
917	kfunc: K option
918	kfunc: K option
919	kfunc: K option
920	kfunc: leave
921	line 50: OPTIND=2
922	line 60: ret=1, optc=?, OPTIND=2
923---
924
925
926name: regression-54
927description:
928	Check that ; is not required before the then in if (( ... )) then ...
929stdin:
930	if (( 1 )) then
931	    echo ok dparen
932	fi
933	if [[ -n 1 ]] then
934	    echo ok dbrackets
935	fi
936expected-stdout:
937	ok dparen
938	ok dbrackets
939---
940
941
942name: regression-55
943description:
944	Check ${foo:%bar} is allowed (ksh88 allows it...)
945stdin:
946	x=fooXbarXblah
947	echo 1 ${x%X*}
948	echo 2 ${x:%X*}
949	echo 3 ${x%%X*}
950	echo 4 ${x:%%X*}
951	echo 5 ${x#*X}
952	echo 6 ${x:#*X}
953	echo 7 ${x##*X}
954	echo 8 ${x:##*X}
955expected-stdout:
956	1 fooXbar
957	2 fooXbar
958	3 foo
959	4 foo
960	5 barXblah
961	6 barXblah
962	7 blah
963	8 blah
964---
965
966
967name: regression-56
968description:
969	Check eval vs substitution exit codes
970	(this is what ksh88 does)
971stdin:
972	eval $(false)
973	echo A $?
974	eval ' $(false)'
975	echo B $?
976	eval " $(false)"
977	echo C $?
978	eval "eval $(false)"
979	echo D $?
980	eval 'eval '"$(false)"
981	echo E $?
982	IFS="$IFS:"
983	eval $(echo :; false)
984	echo F $?
985expected-stdout:
986	A 1
987	B 1
988	C 1
989	D 0
990	E 0
991	F 1
992---
993
994name: regression-57
995description:
996	Check if typeset output is correct for
997	uninitialized array elements.
998stdin:
999	typeset -i xxx[4]
1000	echo A
1001	typeset -i | grep xxx | sed 's/^/    /'
1002	echo B
1003	typeset | grep xxx | sed 's/^/    /'
1004
1005	xxx[1]=2+5
1006	echo M
1007	typeset -i | grep xxx | sed 's/^/    /'
1008	echo N
1009	typeset | grep xxx | sed 's/^/    /'
1010expected-stdout:
1011	A
1012	    xxx
1013	B
1014	    typeset -i xxx
1015	M
1016	    xxx[1]=7
1017	N
1018	    typeset -i xxx
1019---
1020
1021name: regression-58
1022description:
1023	Check if trap exit is ok (exit not mistaken for signal name)
1024stdin:
1025	trap 'echo hi' exit
1026	trap exit 1
1027expected-stdout:
1028	hi
1029---
1030
1031name: regression-59
1032description:
1033	Check if ${#array[*]} is calculated correctly.
1034stdin:
1035	a[12]=hi
1036	a[8]=there
1037	echo ${#a[*]}
1038expected-stdout:
1039	2
1040---
1041
1042name: regression-60
1043description:
1044	Check if default exit status is previous command
1045stdin:
1046	(true; exit)
1047	echo A $?
1048	(false; exit)
1049	echo B $?
1050	( (exit 103) ; exit)
1051	echo C $?
1052expected-stdout:
1053	A 0
1054	B 1
1055	C 103
1056---
1057
1058name: regression-61
1059description:
1060	Check if EXIT trap is executed for sub shells.
1061stdin:
1062	trap 'echo parent exit' EXIT
1063	echo start
1064	(echo A; echo A last)
1065	echo B
1066	(echo C; trap 'echo sub exit' EXIT; echo C last)
1067	echo parent last
1068expected-stdout:
1069	start
1070	A
1071	A last
1072	B
1073	C
1074	C last
1075	sub exit
1076	parent last
1077	parent exit
1078---
1079
1080name: regression-62
1081description:
1082	Check if test -nt/-ot succeeds if second(first) file is missing.
1083stdin:
1084	touch a
1085	test a -nt b && echo nt OK || echo nt BAD
1086	test b -ot a && echo ot OK || echo ot BAD
1087expected-stdout:
1088	nt OK
1089	ot OK
1090---
1091
1092name: regression-63
1093description:
1094	Check octal escape expansion in prompts.
1095file-setup: file 644 "env"
1096	PS1=\\131
1097	PS2=\\130
1098env-setup: !ENV=./env!
1099arguments: !-i!
1100stdin:
1101	echo hello
1102	for i in 1 2 3; do
1103		echo there
1104	done
1105expected-stdout:
1106	hello
1107	there
1108	there
1109	there
1110expected-stderr: !
1111	YYXXY
1112---
1113