Home | History | Annotate | Download | only in src
      1 # $MirOS: src/bin/mksh/check.t,v 1.483 2011/10/07 19:51:42 tg Exp $
      2 # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
      3 # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
      4 # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
      5 #-
      6 # Copyright  2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
      7 #	Thorsten Glaser <tg (a] mirbsd.org>
      8 #
      9 # Provided that these terms and disclaimer and all copyright notices
     10 # are retained or reproduced in an accompanying document, permission
     11 # is granted to deal in this work without restriction, including un
     12 # limited rights to use, publicly perform, distribute, sell, modify,
     13 # merge, give away, or sublicence.
     14 #
     15 # This work is provided AS IS and WITHOUT WARRANTY of any kind, to
     16 # the utmost extent permitted by applicable law, neither express nor
     17 # implied; without malicious intent or gross negligence. In no event
     18 # may a licensor, author or contributor be held liable for indirect,
     19 # direct, other damage, loss, or other issues arising in any way out
     20 # of dealing in the work, even if advised of the possibility of such
     21 # damage or existence of a defect, except proven that it results out
     22 # of said persons immediate fault when using the work as intended.
     23 #-
     24 # You may also want to test IFS with the script at
     25 # http://www.research.att.com/~gsf/public/ifs.sh
     26 
     27 expected-stdout:
     28 	@(#)MIRBSD KSH R40 2011/10/07
     29 description:
     30 	Check version of shell.
     31 stdin:
     32 	echo $KSH_VERSION
     33 name: KSH_VERSION
     34 ---
     35 name: selftest-1
     36 description:
     37 	Regression test self-testing
     38 stdin:
     39 	echo ${foo:-baz}
     40 expected-stdout:
     41 	baz
     42 ---
     43 name: selftest-2
     44 description:
     45 	Regression test self-testing
     46 env-setup: !foo=bar!
     47 stdin:
     48 	echo ${foo:-baz}
     49 expected-stdout:
     50 	bar
     51 ---
     52 name: selftest-3
     53 description:
     54 	Regression test self-testing
     55 env-setup: !ENV=fnord!
     56 stdin:
     57 	echo "<$ENV>"
     58 expected-stdout:
     59 	<fnord>
     60 ---
     61 name: selftest-env
     62 description:
     63 	Just output the environment variables set (always fails)
     64 category: disabled
     65 stdin:
     66 	set
     67 ---
     68 name: selftest-direct-builtin-call
     69 description:
     70 	Check that direct builtin calls work
     71 stdin:
     72 	ln -s "$__progname" cat
     73 	ln -s "$__progname" echo
     74 	./echo -c 'echo  foo' | ./cat -u
     75 expected-stdout:
     76 	-c echo  foo
     77 ---
     78 name: alias-1
     79 description:
     80 	Check that recursion is detected/avoided in aliases.
     81 stdin:
     82 	alias fooBar=fooBar
     83 	fooBar
     84 	exit 0
     85 expected-stderr-pattern:
     86 	/fooBar.*not found.*/
     87 ---
     88 name: alias-2
     89 description:
     90 	Check that recursion is detected/avoided in aliases.
     91 stdin:
     92 	alias fooBar=barFoo
     93 	alias barFoo=fooBar
     94 	fooBar
     95 	barFoo
     96 	exit 0
     97 expected-stderr-pattern:
     98 	/fooBar.*not found.*\n.*barFoo.*not found/
     99 ---
    100 name: alias-3
    101 description:
    102 	Check that recursion is detected/avoided in aliases.
    103 stdin:
    104 	alias Echo='echo '
    105 	alias fooBar=barFoo
    106 	alias barFoo=fooBar
    107 	Echo fooBar
    108 	unalias barFoo
    109 	Echo fooBar
    110 expected-stdout:
    111 	fooBar
    112 	barFoo
    113 ---
    114 name: alias-4
    115 description:
    116 	Check that alias expansion isn't done on keywords (in keyword
    117 	postitions).
    118 stdin:
    119 	alias Echo='echo '
    120 	alias while=While
    121 	while false; do echo hi ; done
    122 	Echo while
    123 expected-stdout:
    124 	While
    125 ---
    126 name: alias-5
    127 description:
    128 	Check that alias expansion done after alias with trailing space.
    129 stdin:
    130 	alias Echo='echo '
    131 	alias foo='bar stuff '
    132 	alias bar='Bar1 Bar2 '
    133 	alias stuff='Stuff'
    134 	alias blah='Blah'
    135 	Echo foo blah
    136 expected-stdout:
    137 	Bar1 Bar2 Stuff Blah
    138 ---
    139 name: alias-6
    140 description:
    141 	Check that alias expansion done after alias with trailing space.
    142 stdin:
    143 	alias Echo='echo '
    144 	alias foo='bar bar'
    145 	alias bar='Bar '
    146 	alias blah=Blah
    147 	Echo foo blah
    148 expected-stdout:
    149 	Bar Bar Blah
    150 ---
    151 name: alias-7
    152 description:
    153 	Check that alias expansion done after alias with trailing space
    154 	after a keyword.
    155 stdin:
    156 	alias X='case '
    157 	alias Y=Z
    158 	X Y in 'Y') echo is y ;; Z) echo is z ; esac
    159 expected-stdout:
    160 	is z
    161 ---
    162 name: alias-8
    163 description:
    164 	Check that newlines in an alias don't cause the command to be lost.
    165 stdin:
    166 	alias foo='
    167 	
    168 	
    169 	echo hi
    170 	
    171 	
    172 	
    173 	echo there
    174 	
    175 	
    176 	'
    177 	foo
    178 expected-stdout:
    179 	hi
    180 	there
    181 ---
    182 name: alias-9
    183 description:
    184 	Check that recursion is detected/avoided in aliases.
    185 	This check fails for slow machines or Cygwin, raise
    186 	the time-limit clause (e.g. to 7) if this occurs.
    187 time-limit: 3
    188 stdin:
    189 	echo -n >tf
    190 	alias ls=ls
    191 	ls
    192 	echo $(ls)
    193 	exit 0
    194 expected-stdout:
    195 	tf
    196 	tf
    197 ---
    198 name: alias-10
    199 description:
    200 	Check that recursion is detected/avoided in aliases.
    201 	Regression, introduced during an old bugfix.
    202 stdin:
    203 	alias foo='print hello '
    204 	alias bar='foo world'
    205 	echo $(bar)
    206 expected-stdout:
    207 	hello world
    208 ---
    209 name: arith-lazy-1
    210 description:
    211 	Check that only one side of ternary operator is evaluated
    212 stdin:
    213 	x=i+=2
    214 	y=j+=2
    215 	typeset -i i=1 j=1
    216 	echo $((1 ? 20 : (x+=2)))
    217 	echo $i,$x
    218 	echo $((0 ? (y+=2) : 30))
    219 	echo $j,$y
    220 expected-stdout:
    221 	20
    222 	1,i+=2
    223 	30
    224 	1,j+=2
    225 ---
    226 name: arith-lazy-2
    227 description:
    228 	Check that assignments not done on non-evaluated side of ternary
    229 	operator
    230 stdin:
    231 	x=i+=2
    232 	y=j+=2
    233 	typeset -i i=1 j=1
    234 	echo $((1 ? 20 : (x+=2)))
    235 	echo $i,$x
    236 	echo $((0 ? (y+=2) : 30))
    237 	echo $i,$y
    238 expected-stdout:
    239 	20
    240 	1,i+=2
    241 	30
    242 	1,j+=2
    243 ---
    244 name: arith-lazy-3
    245 description:
    246 	Check that assignments not done on non-evaluated side of ternary
    247 	operator and this construct is parsed correctly (Debian #445651)
    248 stdin:
    249 	x=4
    250 	y=$((0 ? x=1 : 2))
    251 	echo = $x $y =
    252 expected-stdout:
    253 	= 4 2 =
    254 ---
    255 name: arith-ternary-prec-1
    256 description:
    257 	Check precedence of ternary operator vs assignment
    258 stdin:
    259 	typeset -i x=2
    260 	y=$((1 ? 20 : x+=2))
    261 expected-exit: e != 0
    262 expected-stderr-pattern:
    263 	/.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
    264 ---
    265 name: arith-ternary-prec-2
    266 description:
    267 	Check precedence of ternary operator vs assignment
    268 stdin:
    269 	typeset -i x=2
    270 	echo $((0 ? x+=2 : 20))
    271 expected-stdout:
    272 	20
    273 ---
    274 name: arith-div-assoc-1
    275 description:
    276 	Check associativity of division operator
    277 stdin:
    278 	echo $((20 / 2 / 2))
    279 expected-stdout:
    280 	5
    281 ---
    282 name: arith-assop-assoc-1
    283 description:
    284 	Check associativity of assignment-operator operator
    285 stdin:
    286 	typeset -i i=1 j=2 k=3
    287 	echo $((i += j += k))
    288 	echo $i,$j,$k
    289 expected-stdout:
    290 	6
    291 	6,5,3
    292 ---
    293 name: arith-unsigned-1
    294 description:
    295 	Check if unsigned arithmetics work
    296 stdin:
    297 	# signed vs unsigned
    298 	echo x1 $((-1)) $((#-1))
    299 	# calculating
    300 	typeset -i vs
    301 	typeset -Ui vu
    302 	vs=4123456789; vu=4123456789
    303 	echo x2 $vs $vu
    304 	(( vs %= 2147483647 ))
    305 	(( vu %= 2147483647 ))
    306 	echo x3 $vs $vu
    307 	vs=4123456789; vu=4123456789
    308 	(( # vs %= 2147483647 ))
    309 	(( # vu %= 2147483647 ))
    310 	echo x4 $vs $vu
    311 	# make sure the calculation does not change unsigned flag
    312 	vs=4123456789; vu=4123456789
    313 	echo x5 $vs $vu
    314 	# short form
    315 	echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
    316 	# array refs
    317 	set -A va
    318 	va[1975973142]=right
    319 	va[4123456789]=wrong
    320 	echo x7 ${va[#4123456789%2147483647]}
    321 expected-stdout:
    322 	x1 -1 4294967295
    323 	x2 -171510507 4123456789
    324 	x3 -171510507 4123456789
    325 	x4 1975973142 1975973142
    326 	x5 -171510507 4123456789
    327 	x6 1975973142 1975973142
    328 	x7 right
    329 ---
    330 name: arith-limit32-1
    331 description:
    332 	Check if arithmetics are 32 bit
    333 stdin:
    334 	# signed vs unsigned
    335 	echo x1 $((-1)) $((#-1))
    336 	# calculating
    337 	typeset -i vs
    338 	typeset -Ui vu
    339 	vs=2147483647; vu=2147483647
    340 	echo x2 $vs $vu
    341 	let vs++ vu++
    342 	echo x3 $vs $vu
    343 	vs=4294967295; vu=4294967295
    344 	echo x4 $vs $vu
    345 	let vs++ vu++
    346 	echo x5 $vs $vu
    347 	let vs++ vu++
    348 	echo x6 $vs $vu
    349 expected-stdout:
    350 	x1 -1 4294967295
    351 	x2 2147483647 2147483647
    352 	x3 -2147483648 2147483648
    353 	x4 -1 4294967295
    354 	x5 0 0
    355 	x6 1 1
    356 ---
    357 name: bksl-nl-ign-1
    358 description:
    359 	Check that \newline is not collapsed after #
    360 stdin:
    361 	echo hi #there \
    362 	echo folks
    363 expected-stdout:
    364 	hi
    365 	folks
    366 ---
    367 name: bksl-nl-ign-2
    368 description:
    369 	Check that \newline is not collapsed inside single quotes
    370 stdin:
    371 	echo 'hi \
    372 	there'
    373 	echo folks
    374 expected-stdout:
    375 	hi \
    376 	there
    377 	folks
    378 ---
    379 name: bksl-nl-ign-3
    380 description:
    381 	Check that \newline is not collapsed inside single quotes
    382 stdin:
    383 	cat << \EOF
    384 	hi \
    385 	there
    386 	EOF
    387 expected-stdout:
    388 	hi \
    389 	there
    390 ---
    391 name: bksl-nl-ign-4
    392 description:
    393 	Check interaction of aliases, single quotes and here-documents
    394 	with backslash-newline
    395 	(don't know what POSIX has to say about this)
    396 stdin:
    397 	a=2
    398 	alias x='echo hi
    399 	cat << "EOF"
    400 	foo\
    401 	bar
    402 	some'
    403 	x
    404 	more\
    405 	stuff$a
    406 	EOF
    407 expected-stdout:
    408 	hi
    409 	foo\
    410 	bar
    411 	some
    412 	more\
    413 	stuff$a
    414 ---
    415 name: bksl-nl-ign-5
    416 description:
    417 	Check what happens with backslash at end of input
    418 	(the old Bourne shell trashes them; so do we)
    419 stdin: !
    420 	echo `echo foo\\`bar
    421 	echo hi\
    422 expected-stdout:
    423 	foobar
    424 	hi
    425 ---
    426 #
    427 # Places \newline should be collapsed
    428 #
    429 name: bksl-nl-1
    430 description:
    431 	Check that \newline is collapsed before, in the middle of, and
    432 	after words
    433 stdin:
    434 	 	 	\
    435 			 echo hi\
    436 	There, \
    437 	folks
    438 expected-stdout:
    439 	hiThere, folks
    440 ---
    441 name: bksl-nl-2
    442 description:
    443 	Check that \newline is collapsed in $ sequences
    444 	(ksh93 fails this)
    445 stdin:
    446 	a=12
    447 	ab=19
    448 	echo $\
    449 	a
    450 	echo $a\
    451 	b
    452 	echo $\
    453 	{a}
    454 	echo ${a\
    455 	b}
    456 	echo ${ab\
    457 	}
    458 expected-stdout:
    459 	12
    460 	19
    461 	12
    462 	19
    463 	19
    464 ---
    465 name: bksl-nl-3
    466 description:
    467 	Check that \newline is collapsed in $(..) and `...` sequences
    468 	(ksh93 fails this)
    469 stdin:
    470 	echo $\
    471 	(echo foobar1)
    472 	echo $(\
    473 	echo foobar2)
    474 	echo $(echo foo\
    475 	bar3)
    476 	echo $(echo foobar4\
    477 	)
    478 	echo `
    479 	echo stuff1`
    480 	echo `echo st\
    481 	uff2`
    482 expected-stdout:
    483 	foobar1
    484 	foobar2
    485 	foobar3
    486 	foobar4
    487 	stuff1
    488 	stuff2
    489 ---
    490 name: bksl-nl-4
    491 description:
    492 	Check that \newline is collapsed in $((..)) sequences
    493 	(ksh93 fails this)
    494 stdin:
    495 	echo $\
    496 	((1+2))
    497 	echo $(\
    498 	(1+2+3))
    499 	echo $((\
    500 	1+2+3+4))
    501 	echo $((1+\
    502 	2+3+4+5))
    503 	echo $((1+2+3+4+5+6)\
    504 	)
    505 expected-stdout:
    506 	3
    507 	6
    508 	10
    509 	15
    510 	21
    511 ---
    512 name: bksl-nl-5
    513 description:
    514 	Check that \newline is collapsed in double quoted strings
    515 stdin:
    516 	echo "\
    517 	hi"
    518 	echo "foo\
    519 	bar"
    520 	echo "folks\
    521 	"
    522 expected-stdout:
    523 	hi
    524 	foobar
    525 	folks
    526 ---
    527 name: bksl-nl-6
    528 description:
    529 	Check that \newline is collapsed in here document delimiters
    530 	(ksh93 fails second part of this)
    531 stdin:
    532 	a=12
    533 	cat << EO\
    534 	F
    535 	a=$a
    536 	foo\
    537 	bar
    538 	EOF
    539 	cat << E_O_F
    540 	foo
    541 	E_O_\
    542 	F
    543 	echo done
    544 expected-stdout:
    545 	a=12
    546 	foobar
    547 	foo
    548 	done
    549 ---
    550 name: bksl-nl-7
    551 description:
    552 	Check that \newline is collapsed in double-quoted here-document
    553 	delimiter.
    554 stdin:
    555 	a=12
    556 	cat << "EO\
    557 	F"
    558 	a=$a
    559 	foo\
    560 	bar
    561 	EOF
    562 	echo done
    563 expected-stdout:
    564 	a=$a
    565 	foo\
    566 	bar
    567 	done
    568 ---
    569 name: bksl-nl-8
    570 description:
    571 	Check that \newline is collapsed in various 2+ character tokens
    572 	delimiter.
    573 	(ksh93 fails this)
    574 stdin:
    575 	echo hi &\
    576 	& echo there
    577 	echo foo |\
    578 	| echo bar
    579 	cat <\
    580 	< EOF
    581 	stuff
    582 	EOF
    583 	cat <\
    584 	<\
    585 	- EOF
    586 		more stuff
    587 	EOF
    588 	cat <<\
    589 	EOF
    590 	abcdef
    591 	EOF
    592 	echo hi >\
    593 	> /dev/null
    594 	echo $?
    595 	i=1
    596 	case $i in
    597 	(\
    598 	x|\
    599 	1\
    600 	) echo hi;\
    601 	;
    602 	(*) echo oops
    603 	esac
    604 expected-stdout:
    605 	hi
    606 	there
    607 	foo
    608 	stuff
    609 	more stuff
    610 	abcdef
    611 	0
    612 	hi
    613 ---
    614 name: bksl-nl-9
    615 description:
    616 	Check that \ at the end of an alias is collapsed when followed
    617 	by a newline
    618 	(don't know what POSIX has to say about this)
    619 stdin:
    620 	alias x='echo hi\'
    621 	x
    622 	echo there
    623 expected-stdout:
    624 	hiecho there
    625 ---
    626 name: bksl-nl-10
    627 description:
    628 	Check that \newline in a keyword is collapsed
    629 stdin:
    630 	i\
    631 	f true; then\
    632 	 echo pass; el\
    633 	se echo fail; fi
    634 expected-stdout:
    635 	pass
    636 ---
    637 #
    638 # Places \newline should be collapsed (ksh extensions)
    639 #
    640 name: bksl-nl-ksh-1
    641 description:
    642 	Check that \newline is collapsed in extended globbing
    643 	(ksh93 fails this)
    644 stdin:
    645 	xxx=foo
    646 	case $xxx in
    647 	(f*\
    648 	(\
    649 	o\
    650 	)\
    651 	) echo ok ;;
    652 	*) echo bad
    653 	esac
    654 expected-stdout:
    655 	ok
    656 ---
    657 name: bksl-nl-ksh-2
    658 description:
    659 	Check that \newline is collapsed in ((...)) expressions
    660 	(ksh93 fails this)
    661 stdin:
    662 	i=1
    663 	(\
    664 	(\
    665 	i=i+2\
    666 	)\
    667 	)
    668 	echo $i
    669 expected-stdout:
    670 	3
    671 ---
    672 name: break-1
    673 description:
    674 	See if break breaks out of loops
    675 stdin:
    676 	for i in a b c; do echo $i; break; echo bad-$i; done
    677 	echo end-1
    678 	for i in a b c; do echo $i; break 1; echo bad-$i; done
    679 	echo end-2
    680 	for i in a b c; do
    681 	    for j in x y z; do
    682 		echo $i:$j
    683 		break
    684 		echo bad-$i
    685 	    done
    686 	    echo end-$i
    687 	done
    688 	echo end-3
    689 expected-stdout:
    690 	a
    691 	end-1
    692 	a
    693 	end-2
    694 	a:x
    695 	end-a
    696 	b:x
    697 	end-b
    698 	c:x
    699 	end-c
    700 	end-3
    701 ---
    702 name: break-2
    703 description:
    704 	See if break breaks out of nested loops
    705 stdin:
    706 	for i in a b c; do
    707 	    for j in x y z; do
    708 		echo $i:$j
    709 		break 2
    710 		echo bad-$i
    711 	    done
    712 	    echo end-$i
    713 	done
    714 	echo end
    715 expected-stdout:
    716 	a:x
    717 	end
    718 ---
    719 name: break-3
    720 description:
    721 	What if break used outside of any loops
    722 	(ksh88,ksh93 don't print error messages here)
    723 stdin:
    724 	break
    725 expected-stderr-pattern:
    726 	/.*break.*/
    727 ---
    728 name: break-4
    729 description:
    730 	What if break N used when only N-1 loops
    731 	(ksh88,ksh93 don't print error messages here)
    732 stdin:
    733 	for i in a b c; do echo $i; break 2; echo bad-$i; done
    734 	echo end
    735 expected-stdout:
    736 	a
    737 	end
    738 expected-stderr-pattern:
    739 	/.*break.*/
    740 ---
    741 name: break-5
    742 description:
    743 	Error if break argument isn't a number
    744 stdin:
    745 	for i in a b c; do echo $i; break abc; echo more-$i; done
    746 	echo end
    747 expected-stdout:
    748 	a
    749 expected-exit: e != 0
    750 expected-stderr-pattern:
    751 	/.*break.*/
    752 ---
    753 name: continue-1
    754 description:
    755 	See if continue continues loops
    756 stdin:
    757 	for i in a b c; do echo $i; continue; echo bad-$i ; done
    758 	echo end-1
    759 	for i in a b c; do echo $i; continue 1; echo bad-$i; done
    760 	echo end-2
    761 	for i in a b c; do
    762 	    for j in x y z; do
    763 		echo $i:$j
    764 		continue
    765 		echo bad-$i-$j
    766 	    done
    767 	    echo end-$i
    768 	done
    769 	echo end-3
    770 expected-stdout:
    771 	a
    772 	b
    773 	c
    774 	end-1
    775 	a
    776 	b
    777 	c
    778 	end-2
    779 	a:x
    780 	a:y
    781 	a:z
    782 	end-a
    783 	b:x
    784 	b:y
    785 	b:z
    786 	end-b
    787 	c:x
    788 	c:y
    789 	c:z
    790 	end-c
    791 	end-3
    792 ---
    793 name: continue-2
    794 description:
    795 	See if continue breaks out of nested loops
    796 stdin:
    797 	for i in a b c; do
    798 	    for j in x y z; do
    799 		echo $i:$j
    800 		continue 2
    801 		echo bad-$i-$j
    802 	    done
    803 	    echo end-$i
    804 	done
    805 	echo end
    806 expected-stdout:
    807 	a:x
    808 	b:x
    809 	c:x
    810 	end
    811 ---
    812 name: continue-3
    813 description:
    814 	What if continue used outside of any loops
    815 	(ksh88,ksh93 don't print error messages here)
    816 stdin:
    817 	continue
    818 expected-stderr-pattern:
    819 	/.*continue.*/
    820 ---
    821 name: continue-4
    822 description:
    823 	What if continue N used when only N-1 loops
    824 	(ksh88,ksh93 don't print error messages here)
    825 stdin:
    826 	for i in a b c; do echo $i; continue 2; echo bad-$i; done
    827 	echo end
    828 expected-stdout:
    829 	a
    830 	b
    831 	c
    832 	end
    833 expected-stderr-pattern:
    834 	/.*continue.*/
    835 ---
    836 name: continue-5
    837 description:
    838 	Error if continue argument isn't a number
    839 stdin:
    840 	for i in a b c; do echo $i; continue abc; echo more-$i; done
    841 	echo end
    842 expected-stdout:
    843 	a
    844 expected-exit: e != 0
    845 expected-stderr-pattern:
    846 	/.*continue.*/
    847 ---
    848 name: cd-history
    849 description:
    850 	Test someone's CD history package (uses arrays)
    851 stdin:
    852 	# go to known place before doing anything
    853 	cd /
    854 	
    855 	alias cd=_cd
    856 	function _cd
    857 	{
    858 		typeset -i cdlen i
    859 		typeset t
    860 	
    861 		if [ $# -eq 0 ]
    862 		then
    863 			set -- $HOME
    864 		fi
    865 	
    866 		if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
    867 		then
    868 			typeset CDHIST
    869 			i=-1
    870 			while read -r t			# read directory history file
    871 			do
    872 				CDHIST[i=i+1]=$t
    873 			done <$CDHISTFILE
    874 		fi
    875 	
    876 		if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
    877 		then
    878 			_cdins				# insert $PWD into cd history
    879 		fi
    880 	
    881 		cdlen=${#CDHIST[*]}			# number of elements in history
    882 	
    883 		case "$@" in
    884 		-)					# cd to new dir
    885 			if [ "$OLDPWD" = "" ] && ((cdlen>1))
    886 			then
    887 				'print' ${CDHIST[1]}
    888 				'cd' ${CDHIST[1]}
    889 				_pwd
    890 			else
    891 				'cd' $@
    892 				_pwd
    893 			fi
    894 			;;
    895 		-l)					# print directory list
    896 			typeset -R3 num
    897 			((i=cdlen))
    898 			while (((i=i-1)>=0))
    899 			do
    900 				num=$i
    901 				'print' "$num ${CDHIST[i]}"
    902 			done
    903 			return
    904 			;;
    905 		-[0-9]|-[0-9][0-9])			# cd to dir in list
    906 			if (((i=${1#-})<cdlen))
    907 			then
    908 				'print' ${CDHIST[i]}
    909 				'cd' ${CDHIST[i]}
    910 				_pwd
    911 			else
    912 				'cd' $@
    913 				_pwd
    914 			fi
    915 			;;
    916 		-*)					# cd to matched dir in list
    917 			t=${1#-}
    918 			i=1
    919 			while ((i<cdlen))
    920 			do
    921 				case ${CDHIST[i]} in
    922 				*$t*)
    923 					'print' ${CDHIST[i]}
    924 					'cd' ${CDHIST[i]}
    925 					_pwd
    926 					break
    927 					;;
    928 				esac
    929 				((i=i+1))
    930 			done
    931 			if ((i>=cdlen))
    932 			then
    933 				'cd' $@
    934 				_pwd
    935 			fi
    936 			;;
    937 		*)					# cd to new dir
    938 			'cd' $@
    939 			_pwd
    940 			;;
    941 		esac
    942 	
    943 		_cdins					# insert $PWD into cd history
    944 	
    945 		if [ "$CDHISTFILE" ]
    946 		then
    947 			cdlen=${#CDHIST[*]}		# number of elements in history
    948 	
    949 			i=0
    950 			while ((i<cdlen))
    951 			do
    952 				'print' -r ${CDHIST[i]}	# update directory history
    953 				((i=i+1))
    954 			done >$CDHISTFILE
    955 		fi
    956 	}
    957 	
    958 	function _cdins					# insert $PWD into cd history
    959 	{						# meant to be called only by _cd
    960 		typeset -i i
    961 	
    962 		((i=0))
    963 		while ((i<${#CDHIST[*]}))		# see if dir is already in list
    964 		do
    965 			if [ "${CDHIST[$i]}" = "$PWD" ]
    966 			then
    967 				break
    968 			fi
    969 			((i=i+1))
    970 		done
    971 	
    972 		if ((i>22))				# limit max size of list
    973 		then
    974 			i=22
    975 		fi
    976 	
    977 		while (((i=i-1)>=0))			# bump old dirs in list
    978 		do
    979 			CDHIST[i+1]=${CDHIST[i]}
    980 		done
    981 	
    982 		CDHIST[0]=$PWD				# insert new directory in list
    983 	}
    984 	
    985 	
    986 	function _pwd
    987 	{
    988 		if [ -n "$ECD" ]
    989 		then
    990 			pwd 1>&6
    991 		fi
    992 	}
    993 	# Start of test
    994 	cd /tmp
    995 	cd /bin
    996 	cd /etc
    997 	cd -
    998 	cd -2
    999 	cd -l
   1000 expected-stdout:
   1001 	/bin
   1002 	/tmp
   1003 	  3 /
   1004 	  2 /etc
   1005 	  1 /bin
   1006 	  0 /tmp
   1007 ---
   1008 name: cd-pe
   1009 description:
   1010 	Check package for cd -Pe
   1011 need-pass: no
   1012 # the mv command fails on Cygwin
   1013 category: !os:cygwin
   1014 file-setup: file 644 "x"
   1015 	mkdir noread noread/target noread/target/subdir
   1016 	ln -s noread link
   1017 	chmod 311 noread
   1018 	cd -P$1 .
   1019 	echo 0=$?
   1020 	bwd=$PWD
   1021 	cd -P$1 link/target
   1022 	echo 1=$?,${PWD#$bwd/}
   1023 	epwd=$($TSHELL -c pwd 2>/dev/null)
   1024 	# This unexpectedly succeeds on GNU/Linux and MidnightBSD
   1025 	#echo pwd=$?,$epwd
   1026 	# expect:	pwd=1,
   1027 	mv ../../noread ../../renamed
   1028 	cd -P$1 subdir
   1029 	echo 2=$?,${PWD#$bwd/}
   1030 	cd $bwd
   1031 	chmod 755 renamed
   1032 	rm -rf noread link renamed
   1033 stdin:
   1034 	export TSHELL="$__progname"
   1035 	"$__progname" x
   1036 	echo "now with -e:"
   1037 	"$__progname" x e
   1038 expected-stdout:
   1039 	0=0
   1040 	1=0,noread/target
   1041 	2=0,noread/target/subdir
   1042 	now with -e:
   1043 	0=0
   1044 	1=0,noread/target
   1045 	2=1,noread/target/subdir
   1046 ---
   1047 name: env-prompt
   1048 description:
   1049 	Check that prompt not printed when processing ENV
   1050 env-setup: !ENV=./foo!
   1051 file-setup: file 644 "foo"
   1052 	XXX=_
   1053 	PS1=X
   1054 	false && echo hmmm
   1055 need-ctty: yes
   1056 arguments: !-i!
   1057 stdin:
   1058 	echo hi${XXX}there
   1059 expected-stdout:
   1060 	hi_there
   1061 expected-stderr: !
   1062 	XX
   1063 ---
   1064 name: expand-ugly
   1065 description:
   1066 	Check that weird ${foo+bar} constructs are parsed correctly
   1067 stdin:
   1068 	(echo 1 ${IFS+'}'z}) 2>&- || echo failed in 1
   1069 	(echo 2 "${IFS+'}'z}") 2>&- || echo failed in 2
   1070 	(echo 3 "foo ${IFS+'bar} baz") 2>&- || echo failed in 3
   1071 	(echo -n '4 '; printf '%s\n' "foo ${IFS+"b   c"} baz") 2>&- || echo failed in 4
   1072 	(echo -n '5 '; printf '%s\n' "foo ${IFS+b   c} baz") 2>&- || echo failed in 5
   1073 	(echo 6 ${IFS+"}"z}) 2>&- || echo failed in 6
   1074 	(echo 7 "${IFS+"}"z}") 2>&- || echo failed in 7
   1075 	(echo 8 "${IFS+\"}\"z}") 2>&- || echo failed in 8
   1076 	(echo 9 "${IFS+\"\}\"z}") 2>&- || echo failed in 9
   1077 	(echo 10 foo ${IFS+'bar} baz'}) 2>&- || echo failed in 10
   1078 	(echo 11 "$(echo "${IFS+'}'z}")") 2>&- || echo failed in 11
   1079 	(echo 12 "$(echo ${IFS+'}'z})") 2>&- || echo failed in 12
   1080 	(echo 13 ${IFS+\}z}) 2>&- || echo failed in 13
   1081 	(echo 14 "${IFS+\}z}") 2>&- || echo failed in 14
   1082 	u=x; (echo -n '15 '; printf '<%s> ' "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>&- || echo failed in 15
   1083 	l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>&- || echo failed in 16
   1084 	l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>&- || echo failed in 17
   1085 	l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>&- || echo failed in 18
   1086 	l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>&- || echo failed in 19
   1087 	l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>&- || echo failed in 20
   1088 	l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>&- || echo failed in 21
   1089 	l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>&- || echo failed in 22
   1090 	l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>&- || echo failed in 23
   1091 	key=value; (echo -n '24 '; printf '%s\n' "${IFS+'$key'}") 2>&- || echo failed in 24
   1092 	key=value; (echo -n '25 '; printf '%s\n' "${IFS+"'$key'"}") 2>&- || echo failed in 25	# ksh93: '$key'
   1093 	key=value; (echo -n '26 '; printf '%s\n' ${IFS+'$key'}) 2>&- || echo failed in 26
   1094 	key=value; (echo -n '27 '; printf '%s\n' ${IFS+"'$key'"}) 2>&- || echo failed in 27
   1095 	(echo -n '28 '; printf '%s\n' "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>&- || echo failed in 28
   1096 	u=x; (echo -n '29 '; printf '<%s> ' foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>&- || echo failed in 29
   1097 	(echo -n '30 '; printf '<%s> ' ${IFS+foo 'b\
   1098 	ar' baz}; echo .) 2>&- || (echo failed in 30; echo failed in 31)
   1099 	(echo -n '32 '; printf '<%s> ' ${IFS+foo "b\
   1100 	ar" baz}; echo .) 2>&- || echo failed in 32
   1101 	(echo -n '33 '; printf '<%s> ' "${IFS+foo 'b\
   1102 	ar' baz}"; echo .) 2>&- || echo failed in 33
   1103 	(echo -n '34 '; printf '<%s> ' "${IFS+foo "b\
   1104 	ar" baz}"; echo .) 2>&- || echo failed in 34
   1105 	(echo -n '35 '; printf '<%s> ' ${v=a\ b} x ${v=c\ d}; echo .) 2>&- || echo failed in 35
   1106 	(echo -n '36 '; printf '<%s> ' "${v=a\ b}" x "${v=c\ d}"; echo .) 2>&- || echo failed in 36
   1107 	(echo -n '37 '; printf '<%s> ' ${v-a\ b} x ${v-c\ d}; echo .) 2>&- || echo failed in 37
   1108 	(echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>&- || echo failed in 38
   1109 	foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>&- || echo failed in 39
   1110 	foo="a b c"; (echo -n '40 '; printf '<%s> ' "${foo#a}"; echo .) 2>&- || echo failed in 40
   1111 expected-stdout:
   1112 	1 }z
   1113 	2 ''z}
   1114 	3 foo 'bar baz
   1115 	4 foo b   c baz
   1116 	5 foo b   c baz
   1117 	6 }z
   1118 	7 }z
   1119 	8 ""z}
   1120 	9 "}"z
   1121 	10 foo bar} baz
   1122 	11 ''z}
   1123 	12 }z
   1124 	13 }z
   1125 	14 }z
   1126 	15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
   1127 	16 hi there
   1128 	17 hi there
   1129 	18 hi there
   1130 	19 hi there
   1131 	20 hi there
   1132 	21 hi there
   1133 	22 hi there
   1134 	23 hi there
   1135 	24 'value'
   1136 	25 'value'
   1137 	26 $key
   1138 	27 'value'
   1139 	28 'x ~ x''x}"x}" #
   1140 	29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
   1141 	30 <foo> <b\
   1142 	ar> <baz> .
   1143 	32 <foo> <bar> <baz> .
   1144 	33 <foo 'bar' baz> .
   1145 	34 <foo bar baz> .
   1146 	35 <a> <b> <x> <a> <b> .
   1147 	36 <a\ b> <x> <a\ b> .
   1148 	37 <a b> <x> <c d> .
   1149 	38 xay / x'a'y .
   1150 	39 x' / x' .
   1151 	40 < b c> .
   1152 ---
   1153 name: expand-unglob-dblq
   1154 description:
   1155 	Check that regular "${foo+bar}" constructs are parsed correctly
   1156 stdin:
   1157 	u=x
   1158 	tl_norm() {
   1159 		v=$2
   1160 		test x"$v" = x"-" && unset v
   1161 		(echo "$1 plus norm foo ${v+'bar'} baz")
   1162 		(echo "$1 dash norm foo ${v-'bar'} baz")
   1163 		(echo "$1 eqal norm foo ${v='bar'} baz")
   1164 		(echo "$1 qstn norm foo ${v?'bar'} baz") 2>&- || \
   1165 		    echo "$1 qstn norm -> error"
   1166 		(echo "$1 PLUS norm foo ${v:+'bar'} baz")
   1167 		(echo "$1 DASH norm foo ${v:-'bar'} baz")
   1168 		(echo "$1 EQAL norm foo ${v:='bar'} baz")
   1169 		(echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>&- || \
   1170 		    echo "$1 QSTN norm -> error"
   1171 	}
   1172 	tl_paren() {
   1173 		v=$2
   1174 		test x"$v" = x"-" && unset v
   1175 		(echo "$1 plus parn foo ${v+(bar)} baz")
   1176 		(echo "$1 dash parn foo ${v-(bar)} baz")
   1177 		(echo "$1 eqal parn foo ${v=(bar)} baz")
   1178 		(echo "$1 qstn parn foo ${v?(bar)} baz") 2>&- || \
   1179 		    echo "$1 qstn parn -> error"
   1180 		(echo "$1 PLUS parn foo ${v:+(bar)} baz")
   1181 		(echo "$1 DASH parn foo ${v:-(bar)} baz")
   1182 		(echo "$1 EQAL parn foo ${v:=(bar)} baz")
   1183 		(echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>&- || \
   1184 		    echo "$1 QSTN parn -> error"
   1185 	}
   1186 	tl_brace() {
   1187 		v=$2
   1188 		test x"$v" = x"-" && unset v
   1189 		(echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
   1190 		(echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
   1191 		(echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
   1192 		(echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>&- || \
   1193 		    echo "$1 qstn brac -> error"
   1194 		(echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
   1195 		(echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
   1196 		(echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
   1197 		(echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>&- || \
   1198 		    echo "$1 QSTN brac -> error"
   1199 	}
   1200 	tl_norm 1 -
   1201 	tl_norm 2 ''
   1202 	tl_norm 3 x
   1203 	tl_paren 4 -
   1204 	tl_paren 5 ''
   1205 	tl_paren 6 x
   1206 	tl_brace 7 -
   1207 	tl_brace 8 ''
   1208 	tl_brace 9 x
   1209 expected-stdout:
   1210 	1 plus norm foo  baz
   1211 	1 dash norm foo 'bar' baz
   1212 	1 eqal norm foo 'bar' baz
   1213 	1 qstn norm -> error
   1214 	1 PLUS norm foo  baz
   1215 	1 DASH norm foo 'bar' baz
   1216 	1 EQAL norm foo 'bar' baz
   1217 	1 QSTN norm -> error
   1218 	2 plus norm foo 'bar' baz
   1219 	2 dash norm foo  baz
   1220 	2 eqal norm foo  baz
   1221 	2 qstn norm foo  baz
   1222 	2 PLUS norm foo  baz
   1223 	2 DASH norm foo 'bar' baz
   1224 	2 EQAL norm foo 'bar' baz
   1225 	2 QSTN norm -> error
   1226 	3 plus norm foo 'bar' baz
   1227 	3 dash norm foo x baz
   1228 	3 eqal norm foo x baz
   1229 	3 qstn norm foo x baz
   1230 	3 PLUS norm foo 'bar' baz
   1231 	3 DASH norm foo x baz
   1232 	3 EQAL norm foo x baz
   1233 	3 QSTN norm foo x baz
   1234 	4 plus parn foo  baz
   1235 	4 dash parn foo (bar) baz
   1236 	4 eqal parn foo (bar) baz
   1237 	4 qstn parn -> error
   1238 	4 PLUS parn foo  baz
   1239 	4 DASH parn foo (bar) baz
   1240 	4 EQAL parn foo (bar) baz
   1241 	4 QSTN parn -> error
   1242 	5 plus parn foo (bar) baz
   1243 	5 dash parn foo  baz
   1244 	5 eqal parn foo  baz
   1245 	5 qstn parn foo  baz
   1246 	5 PLUS parn foo  baz
   1247 	5 DASH parn foo (bar) baz
   1248 	5 EQAL parn foo (bar) baz
   1249 	5 QSTN parn -> error
   1250 	6 plus parn foo (bar) baz
   1251 	6 dash parn foo x baz
   1252 	6 eqal parn foo x baz
   1253 	6 qstn parn foo x baz
   1254 	6 PLUS parn foo (bar) baz
   1255 	6 DASH parn foo x baz
   1256 	6 EQAL parn foo x baz
   1257 	6 QSTN parn foo x baz
   1258 	7 plus brac foo  c } baz
   1259 	7 dash brac foo ax{{{}b c d{} baz
   1260 	7 eqal brac foo ax{{{}b c ax{{{}b} baz
   1261 	7 qstn brac -> error
   1262 	7 PLUS brac foo  c } baz
   1263 	7 DASH brac foo ax{{{}b c d{} baz
   1264 	7 EQAL brac foo ax{{{}b c ax{{{}b} baz
   1265 	7 QSTN brac -> error
   1266 	8 plus brac foo ax{{{}b c d{} baz
   1267 	8 dash brac foo  c } baz
   1268 	8 eqal brac foo  c } baz
   1269 	8 qstn brac foo  c } baz
   1270 	8 PLUS brac foo  c } baz
   1271 	8 DASH brac foo ax{{{}b c d{} baz
   1272 	8 EQAL brac foo ax{{{}b c ax{{{}b} baz
   1273 	8 QSTN brac -> error
   1274 	9 plus brac foo ax{{{}b c d{} baz
   1275 	9 dash brac foo x c x} baz
   1276 	9 eqal brac foo x c x} baz
   1277 	9 qstn brac foo x c x} baz
   1278 	9 PLUS brac foo ax{{{}b c d{} baz
   1279 	9 DASH brac foo x c x} baz
   1280 	9 EQAL brac foo x c x} baz
   1281 	9 QSTN brac foo x c x} baz
   1282 ---
   1283 name: expand-unglob-unq
   1284 description:
   1285 	Check that regular ${foo+bar} constructs are parsed correctly
   1286 stdin:
   1287 	u=x
   1288 	tl_norm() {
   1289 		v=$2
   1290 		test x"$v" = x"-" && unset v
   1291 		(echo $1 plus norm foo ${v+'bar'} baz)
   1292 		(echo $1 dash norm foo ${v-'bar'} baz)
   1293 		(echo $1 eqal norm foo ${v='bar'} baz)
   1294 		(echo $1 qstn norm foo ${v?'bar'} baz) 2>&- || \
   1295 		    echo "$1 qstn norm -> error"
   1296 		(echo $1 PLUS norm foo ${v:+'bar'} baz)
   1297 		(echo $1 DASH norm foo ${v:-'bar'} baz)
   1298 		(echo $1 EQAL norm foo ${v:='bar'} baz)
   1299 		(echo $1 QSTN norm foo ${v:?'bar'} baz) 2>&- || \
   1300 		    echo "$1 QSTN norm -> error"
   1301 	}
   1302 	tl_paren() {
   1303 		v=$2
   1304 		test x"$v" = x"-" && unset v
   1305 		(echo $1 plus parn foo ${v+\(bar')'} baz)
   1306 		(echo $1 dash parn foo ${v-\(bar')'} baz)
   1307 		(echo $1 eqal parn foo ${v=\(bar')'} baz)
   1308 		(echo $1 qstn parn foo ${v?\(bar')'} baz) 2>&- || \
   1309 		    echo "$1 qstn parn -> error"
   1310 		(echo $1 PLUS parn foo ${v:+\(bar')'} baz)
   1311 		(echo $1 DASH parn foo ${v:-\(bar')'} baz)
   1312 		(echo $1 EQAL parn foo ${v:=\(bar')'} baz)
   1313 		(echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>&- || \
   1314 		    echo "$1 QSTN parn -> error"
   1315 	}
   1316 	tl_brace() {
   1317 		v=$2
   1318 		test x"$v" = x"-" && unset v
   1319 		(echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
   1320 		(echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
   1321 		(echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
   1322 		(echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>&- || \
   1323 		    echo "$1 qstn brac -> error"
   1324 		(echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
   1325 		(echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
   1326 		(echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
   1327 		(echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>&- || \
   1328 		    echo "$1 QSTN brac -> error"
   1329 	}
   1330 	tl_norm 1 -
   1331 	tl_norm 2 ''
   1332 	tl_norm 3 x
   1333 	tl_paren 4 -
   1334 	tl_paren 5 ''
   1335 	tl_paren 6 x
   1336 	tl_brace 7 -
   1337 	tl_brace 8 ''
   1338 	tl_brace 9 x
   1339 expected-stdout:
   1340 	1 plus norm foo baz
   1341 	1 dash norm foo bar baz
   1342 	1 eqal norm foo bar baz
   1343 	1 qstn norm -> error
   1344 	1 PLUS norm foo baz
   1345 	1 DASH norm foo bar baz
   1346 	1 EQAL norm foo bar baz
   1347 	1 QSTN norm -> error
   1348 	2 plus norm foo bar baz
   1349 	2 dash norm foo baz
   1350 	2 eqal norm foo baz
   1351 	2 qstn norm foo baz
   1352 	2 PLUS norm foo baz
   1353 	2 DASH norm foo bar baz
   1354 	2 EQAL norm foo bar baz
   1355 	2 QSTN norm -> error
   1356 	3 plus norm foo bar baz
   1357 	3 dash norm foo x baz
   1358 	3 eqal norm foo x baz
   1359 	3 qstn norm foo x baz
   1360 	3 PLUS norm foo bar baz
   1361 	3 DASH norm foo x baz
   1362 	3 EQAL norm foo x baz
   1363 	3 QSTN norm foo x baz
   1364 	4 plus parn foo baz
   1365 	4 dash parn foo (bar) baz
   1366 	4 eqal parn foo (bar) baz
   1367 	4 qstn parn -> error
   1368 	4 PLUS parn foo baz
   1369 	4 DASH parn foo (bar) baz
   1370 	4 EQAL parn foo (bar) baz
   1371 	4 QSTN parn -> error
   1372 	5 plus parn foo (bar) baz
   1373 	5 dash parn foo baz
   1374 	5 eqal parn foo baz
   1375 	5 qstn parn foo baz
   1376 	5 PLUS parn foo baz
   1377 	5 DASH parn foo (bar) baz
   1378 	5 EQAL parn foo (bar) baz
   1379 	5 QSTN parn -> error
   1380 	6 plus parn foo (bar) baz
   1381 	6 dash parn foo x baz
   1382 	6 eqal parn foo x baz
   1383 	6 qstn parn foo x baz
   1384 	6 PLUS parn foo (bar) baz
   1385 	6 DASH parn foo x baz
   1386 	6 EQAL parn foo x baz
   1387 	6 QSTN parn foo x baz
   1388 	7 plus brac foo c } baz
   1389 	7 dash brac foo ax{{{}b c d{} baz
   1390 	7 eqal brac foo ax{{{}b c ax{{{}b} baz
   1391 	7 qstn brac -> error
   1392 	7 PLUS brac foo c } baz
   1393 	7 DASH brac foo ax{{{}b c d{} baz
   1394 	7 EQAL brac foo ax{{{}b c ax{{{}b} baz
   1395 	7 QSTN brac -> error
   1396 	8 plus brac foo ax{{{}b c d{} baz
   1397 	8 dash brac foo c } baz
   1398 	8 eqal brac foo c } baz
   1399 	8 qstn brac foo c } baz
   1400 	8 PLUS brac foo c } baz
   1401 	8 DASH brac foo ax{{{}b c d{} baz
   1402 	8 EQAL brac foo ax{{{}b c ax{{{}b} baz
   1403 	8 QSTN brac -> error
   1404 	9 plus brac foo ax{{{}b c d{} baz
   1405 	9 dash brac foo x c x} baz
   1406 	9 eqal brac foo x c x} baz
   1407 	9 qstn brac foo x c x} baz
   1408 	9 PLUS brac foo ax{{{}b c d{} baz
   1409 	9 DASH brac foo x c x} baz
   1410 	9 EQAL brac foo x c x} baz
   1411 	9 QSTN brac foo x c x} baz
   1412 ---
   1413 name: expand-threecolons-dblq
   1414 description:
   1415 	Check for a particular thing that used to segfault
   1416 stdin:
   1417 	TEST=1234
   1418 	echo "${TEST:1:2:3}"
   1419 	echo $? but still living
   1420 expected-stderr-pattern:
   1421 	/bad substitution/
   1422 expected-exit: 1
   1423 ---
   1424 name: expand-threecolons-unq
   1425 description:
   1426 	Check for a particular thing that used to not error out
   1427 stdin:
   1428 	TEST=1234
   1429 	echo ${TEST:1:2:3}
   1430 	echo $? but still living
   1431 expected-stderr-pattern:
   1432 	/bad substitution/
   1433 expected-exit: 1
   1434 ---
   1435 name: expand-weird-1
   1436 description:
   1437 	Check corner case of trim expansion vs. $# vs. ${#var}
   1438 stdin:
   1439 	set 1 2 3 4 5 6 7 8 9 10 11
   1440 	echo ${#}	# value of $#
   1441 	echo ${##}	# length of $#
   1442 	echo ${##1}	# $# trimmed 1
   1443 	set 1 2 3 4 5 6 7 8 9 10 11 12
   1444 	echo ${##1}
   1445 expected-stdout:
   1446 	11
   1447 	2
   1448 	1
   1449 	2
   1450 ---
   1451 name: expand-weird-2
   1452 description:
   1453 	Check corner case of ${var?} vs. ${#var}
   1454 stdin:
   1455 	(exit 0)
   1456 	echo $? = ${#?} .
   1457 	(exit 111)
   1458 	echo $? = ${#?} .
   1459 expected-stdout:
   1460 	0 = 1 .
   1461 	111 = 3 .
   1462 ---
   1463 name: eglob-bad-1
   1464 description:
   1465 	Check that globbing isn't done when glob has syntax error
   1466 file-setup: file 644 "abcx"
   1467 file-setup: file 644 "abcz"
   1468 file-setup: file 644 "bbc"
   1469 stdin:
   1470 	echo !([*)*
   1471 	echo +(a|b[)*
   1472 expected-stdout:
   1473 	!([*)*
   1474 	+(a|b[)*
   1475 ---
   1476 name: eglob-bad-2
   1477 description:
   1478 	Check that globbing isn't done when glob has syntax error
   1479 	(AT&T ksh fails this test)
   1480 file-setup: file 644 "abcx"
   1481 file-setup: file 644 "abcz"
   1482 file-setup: file 644 "bbc"
   1483 stdin:
   1484 	echo [a*(]*)z
   1485 expected-stdout:
   1486 	[a*(]*)z
   1487 ---
   1488 name: eglob-infinite-plus
   1489 description:
   1490 	Check that shell doesn't go into infinite loop expanding +(...)
   1491 	expressions.
   1492 file-setup: file 644 "abc"
   1493 time-limit: 3
   1494 stdin:
   1495 	echo +()c
   1496 	echo +()x
   1497 	echo +(*)c
   1498 	echo +(*)x
   1499 expected-stdout:
   1500 	+()c
   1501 	+()x
   1502 	abc
   1503 	+(*)x
   1504 ---
   1505 name: eglob-subst-1
   1506 description:
   1507 	Check that eglobbing isn't done on substitution results
   1508 file-setup: file 644 "abc"
   1509 stdin:
   1510 	x='@(*)'
   1511 	echo $x
   1512 expected-stdout:
   1513 	@(*)
   1514 ---
   1515 name: eglob-nomatch-1
   1516 description:
   1517 	Check that the pattern doesn't match
   1518 stdin:
   1519 	echo 1: no-file+(a|b)stuff
   1520 	echo 2: no-file+(a*(c)|b)stuff
   1521 	echo 3: no-file+((((c)))|b)stuff
   1522 expected-stdout:
   1523 	1: no-file+(a|b)stuff
   1524 	2: no-file+(a*(c)|b)stuff
   1525 	3: no-file+((((c)))|b)stuff
   1526 ---
   1527 name: eglob-match-1
   1528 description:
   1529 	Check that the pattern matches correctly
   1530 file-setup: file 644 "abd"
   1531 file-setup: file 644 "acd"
   1532 file-setup: file 644 "abac"
   1533 stdin:
   1534 	echo 1: a+(b|c)d
   1535 	echo 2: a!(@(b|B))d
   1536 	echo 3: *(a(b|c))		# (...|...) can be used within X(..)
   1537 	echo 4: a[b*(foo|bar)]d		# patterns not special inside [...]
   1538 expected-stdout:
   1539 	1: abd acd
   1540 	2: acd
   1541 	3: abac
   1542 	4: abd
   1543 ---
   1544 name: eglob-case-1
   1545 description:
   1546 	Simple negation tests
   1547 stdin:
   1548 	case foo in !(foo|bar)) echo yes;; *) echo no;; esac
   1549 	case bar in !(foo|bar)) echo yes;; *) echo no;; esac
   1550 expected-stdout:
   1551 	no
   1552 	no
   1553 ---
   1554 name: eglob-case-2
   1555 description:
   1556 	Simple kleene tests
   1557 stdin:
   1558 	case foo in *(a|b[)) echo yes;; *) echo no;; esac
   1559 	case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
   1560 	case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
   1561 expected-stdout:
   1562 	no
   1563 	yes
   1564 	yes
   1565 ---
   1566 name: eglob-trim-1
   1567 description:
   1568 	Eglobbing in trim expressions...
   1569 	(AT&T ksh fails this - docs say # matches shortest string, ## matches
   1570 	longest...)
   1571 stdin:
   1572 	x=abcdef
   1573 	echo 1: ${x#a|abc}
   1574 	echo 2: ${x##a|abc}
   1575 	echo 3: ${x%def|f}
   1576 	echo 4: ${x%%f|def}
   1577 expected-stdout:
   1578 	1: bcdef
   1579 	2: def
   1580 	3: abcde
   1581 	4: abc
   1582 ---
   1583 name: eglob-trim-2
   1584 description:
   1585 	Check eglobbing works in trims...
   1586 stdin:
   1587 	x=abcdef
   1588 	echo 1: ${x#*(a|b)cd}
   1589 	echo 2: "${x#*(a|b)cd}"
   1590 	echo 3: ${x#"*(a|b)cd"}
   1591 	echo 4: ${x#a(b|c)}
   1592 expected-stdout:
   1593 	1: ef
   1594 	2: ef
   1595 	3: abcdef
   1596 	4: cdef
   1597 ---
   1598 name: eglob-trim-3
   1599 description:
   1600 	Check eglobbing works in trims, for Korn Shell
   1601 	Ensure eglobbing does not work for reduced-feature /bin/sh
   1602 stdin:
   1603 	set +o sh
   1604 	x=foobar
   1605 	y=foobaz
   1606 	z=fooba\?
   1607 	echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
   1608 	echo "<${x%ba(r|z)},${y%ba(r|z)}>"
   1609 	set -o sh
   1610 	echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
   1611 	z='foo(bar'
   1612 	echo "<${z%(*}>"
   1613 expected-stdout:
   1614 	<foo,foo,fooba>
   1615 	<foo,foo>
   1616 	<foobar,foobaz,fooba>
   1617 	<foo>
   1618 ---
   1619 name: eglob-substrpl-1
   1620 description:
   1621 	Check eglobbing works in substs... and they work at all
   1622 stdin:
   1623 	[[ -n $BASH_VERSION ]] && shopt -s extglob
   1624 	x=1222321_ab/cde_b/c_1221
   1625 	y=xyz
   1626 	echo 1: ${x/2}
   1627 	echo 2: ${x//2}
   1628 	echo 3: ${x/+(2)}
   1629 	echo 4: ${x//+(2)}
   1630 	echo 5: ${x/2/4}
   1631 	echo 6: ${x//2/4}
   1632 	echo 7: ${x/+(2)/4}
   1633 	echo 8: ${x//+(2)/4}
   1634 	echo 9: ${x/b/c/e/f}
   1635 	echo 10: ${x/b\/c/e/f}
   1636 	echo 11: ${x/b\/c/e\/f}
   1637 	echo 12: ${x/b\/c/e\\/f}
   1638 	echo 13: ${x/b\\/c/e\\/f}
   1639 	echo 14: ${x//b/c/e/f}
   1640 	echo 15: ${x//b\/c/e/f}
   1641 	echo 16: ${x//b\/c/e\/f}
   1642 	echo 17: ${x//b\/c/e\\/f}
   1643 	echo 18: ${x//b\\/c/e\\/f}
   1644 	echo 19: ${x/b\/*\/c/x}
   1645 	echo 20: ${x/\//.}
   1646 	echo 21: ${x//\//.}
   1647 	echo 22: ${x///.}
   1648 	echo 23: ${x//#1/9}
   1649 	echo 24: ${x//%1/9}
   1650 	echo 25: ${x//\%1/9}
   1651 	echo 26: ${x//\\%1/9}
   1652 	echo 27: ${x//\a/9}
   1653 	echo 28: ${x//\\a/9}
   1654 	echo 29: ${x/2/$y}
   1655 expected-stdout:
   1656 	1: 122321_ab/cde_b/c_1221
   1657 	2: 131_ab/cde_b/c_11
   1658 	3: 1321_ab/cde_b/c_1221
   1659 	4: 131_ab/cde_b/c_11
   1660 	5: 1422321_ab/cde_b/c_1221
   1661 	6: 1444341_ab/cde_b/c_1441
   1662 	7: 14321_ab/cde_b/c_1221
   1663 	8: 14341_ab/cde_b/c_141
   1664 	9: 1222321_ac/e/f/cde_b/c_1221
   1665 	10: 1222321_ae/fde_b/c_1221
   1666 	11: 1222321_ae/fde_b/c_1221
   1667 	12: 1222321_ae\/fde_b/c_1221
   1668 	13: 1222321_ab/cde_b/c_1221
   1669 	14: 1222321_ac/e/f/cde_c/e/f/c_1221
   1670 	15: 1222321_ae/fde_e/f_1221
   1671 	16: 1222321_ae/fde_e/f_1221
   1672 	17: 1222321_ae\/fde_e\/f_1221
   1673 	18: 1222321_ab/cde_b/c_1221
   1674 	19: 1222321_ax_1221
   1675 	20: 1222321_ab.cde_b/c_1221
   1676 	21: 1222321_ab.cde_b.c_1221
   1677 	22: 1222321_ab/cde_b/c_1221
   1678 	23: 9222321_ab/cde_b/c_1221
   1679 	24: 1222321_ab/cde_b/c_1229
   1680 	25: 1222321_ab/cde_b/c_1229
   1681 	26: 1222321_ab/cde_b/c_1221
   1682 	27: 1222321_9b/cde_b/c_1221
   1683 	28: 1222321_9b/cde_b/c_1221
   1684 	29: 1xyz22321_ab/cde_b/c_1221
   1685 ---
   1686 name: eglob-substrpl-2
   1687 description:
   1688 	Check anchored substring replacement works, corner cases
   1689 stdin:
   1690 	foo=123
   1691 	echo 1: ${foo/#/x}
   1692 	echo 2: ${foo/%/x}
   1693 	echo 3: ${foo/#/}
   1694 	echo 4: ${foo/#}
   1695 	echo 5: ${foo/%/}
   1696 	echo 6: ${foo/%}
   1697 expected-stdout:
   1698 	1: x123
   1699 	2: 123x
   1700 	3: 123
   1701 	4: 123
   1702 	5: 123
   1703 	6: 123
   1704 ---
   1705 name: eglob-substrpl-3a
   1706 description:
   1707 	Check substring replacement works with variables and slashes, too
   1708 stdin:
   1709 	pfx=/home/user
   1710 	wd=/home/user/tmp
   1711 	echo "${wd/#$pfx/~}"
   1712 	echo "${wd/#\$pfx/~}"
   1713 	echo "${wd/#"$pfx"/~}"
   1714 	echo "${wd/#'$pfx'/~}"
   1715 	echo "${wd/#"\$pfx"/~}"
   1716 	echo "${wd/#'\$pfx'/~}"
   1717 expected-stdout:
   1718 	~/tmp
   1719 	/home/user/tmp
   1720 	~/tmp
   1721 	/home/user/tmp
   1722 	/home/user/tmp
   1723 	/home/user/tmp
   1724 ---
   1725 name: eglob-substrpl-3b
   1726 description:
   1727 	More of this, bash fails it (bash4 passes)
   1728 stdin:
   1729 	pfx=/home/user
   1730 	wd=/home/user/tmp
   1731 	echo "${wd/#$(echo /home/user)/~}"
   1732 	echo "${wd/#"$(echo /home/user)"/~}"
   1733 	echo "${wd/#'$(echo /home/user)'/~}"
   1734 expected-stdout:
   1735 	~/tmp
   1736 	~/tmp
   1737 	/home/user/tmp
   1738 ---
   1739 name: eglob-substrpl-3c
   1740 description:
   1741 	Even more weird cases
   1742 stdin:
   1743 	pfx=/home/user
   1744 	wd='$pfx/tmp'
   1745 	echo 1: ${wd/#$pfx/~}
   1746 	echo 2: ${wd/#\$pfx/~}
   1747 	echo 3: ${wd/#"$pfx"/~}
   1748 	echo 4: ${wd/#'$pfx'/~}
   1749 	echo 5: ${wd/#"\$pfx"/~}
   1750 	echo 6: ${wd/#'\$pfx'/~}
   1751 	ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
   1752 	tp=a/b
   1753 	tr=c/d
   1754 	[[ -n $BASH_VERSION ]] && shopt -s extglob
   1755 	echo 7: ${ts/a\/b/$tr}
   1756 	echo 8: ${ts/a\/b/\$tr}
   1757 	echo 9: ${ts/$tp/$tr}
   1758 	echo 10: ${ts/\$tp/$tr}
   1759 	echo 11: ${ts/\\$tp/$tr}
   1760 	echo 12: ${ts/$tp/c/d}
   1761 	echo 13: ${ts/$tp/c\/d}
   1762 	echo 14: ${ts/$tp/c\\/d}
   1763 	echo 15: ${ts/+(a\/b)/$tr}
   1764 	echo 16: ${ts/+(a\/b)/\$tr}
   1765 	echo 17: ${ts/+($tp)/$tr}
   1766 	echo 18: ${ts/+($tp)/c/d}
   1767 	echo 19: ${ts/+($tp)/c\/d}
   1768 	echo 25: ${ts//a\/b/$tr}
   1769 	echo 26: ${ts//a\/b/\$tr}
   1770 	echo 27: ${ts//$tp/$tr}
   1771 	echo 28: ${ts//$tp/c/d}
   1772 	echo 29: ${ts//$tp/c\/d}
   1773 	echo 30: ${ts//+(a\/b)/$tr}
   1774 	echo 31: ${ts//+(a\/b)/\$tr}
   1775 	echo 32: ${ts//+($tp)/$tr}
   1776 	echo 33: ${ts//+($tp)/c/d}
   1777 	echo 34: ${ts//+($tp)/c\/d}
   1778 	tp="+($tp)"
   1779 	echo 40: ${ts/$tp/$tr}
   1780 	echo 41: ${ts//$tp/$tr}
   1781 expected-stdout:
   1782 	1: $pfx/tmp
   1783 	2: ~/tmp
   1784 	3: $pfx/tmp
   1785 	4: ~/tmp
   1786 	5: ~/tmp
   1787 	6: ~/tmp
   1788 	7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1789 	8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1790 	9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1791 	10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
   1792 	11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1793 	12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1794 	13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1795 	14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1796 	15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
   1797 	16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
   1798 	17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
   1799 	18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
   1800 	19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
   1801 	25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1802 	26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
   1803 	27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1804 	28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1805 	29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1806 	30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1807 	31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
   1808 	32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1809 	33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1810 	34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1811 	40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1812 	41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
   1813 #	This is what GNU bash does:
   1814 #	40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
   1815 #	41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
   1816 ---
   1817 name: eglob-utf8-1
   1818 description:
   1819 	UTF-8 mode differences for eglobbing
   1820 stdin:
   1821 	s=bld
   1822 	set +U
   1823 	print 1: ${s%???} .
   1824 	print 2: ${s/b???d/x} .
   1825 	set -U
   1826 	print 3: ${s%???} .
   1827 	print 4: ${s/b??d/x} .
   1828 	x=n
   1829 	print 5: ${x%?} ${x%%?} .
   1830 	x=h
   1831 	print 6: ${x#?} ${x##?} .
   1832 	x=
   1833 	print 7: ${x%?} ${x%%?} .
   1834 	x=m
   1835 	print 8: ${x%?} ${x%%?} .
   1836 	x=
   1837 	print 9: ${x%?} ${x%%?} .
   1838 expected-stdout:
   1839 	1: bl .
   1840 	2: x .
   1841 	3: b .
   1842 	4: x .
   1843 	5: n n .
   1844 	6: h h .
   1845 	7:   .
   1846 	8: m m .
   1847 	9: .
   1848 ---
   1849 name: glob-bad-1
   1850 description:
   1851 	Check that globbing isn't done when glob has syntax error
   1852 file-setup: dir 755 "[x"
   1853 file-setup: file 644 "[x/foo"
   1854 stdin:
   1855 	echo [*
   1856 	echo *[x
   1857 	echo [x/*
   1858 expected-stdout:
   1859 	[*
   1860 	*[x
   1861 	[x/foo
   1862 ---
   1863 name: glob-bad-2
   1864 description:
   1865 	Check that symbolic links aren't stat()'d
   1866 # breaks on FreeMiNT (cannot unlink dangling symlinks)
   1867 category: !os:mint
   1868 file-setup: dir 755 "dir"
   1869 file-setup: symlink 644 "dir/abc"
   1870 	non-existent-file
   1871 stdin:
   1872 	echo d*/*
   1873 	echo d*/abc
   1874 expected-stdout:
   1875 	dir/abc
   1876 	dir/abc
   1877 ---
   1878 name: glob-range-1
   1879 description:
   1880 	Test range matching
   1881 file-setup: file 644 ".bc"
   1882 file-setup: file 644 "abc"
   1883 file-setup: file 644 "bbc"
   1884 file-setup: file 644 "cbc"
   1885 file-setup: file 644 "-bc"
   1886 stdin:
   1887 	echo [ab-]*
   1888 	echo [-ab]*
   1889 	echo [!-ab]*
   1890 	echo [!ab]*
   1891 	echo []ab]*
   1892 expected-stdout:
   1893 	-bc abc bbc
   1894 	-bc abc bbc
   1895 	cbc
   1896 	-bc cbc
   1897 	abc bbc
   1898 ---
   1899 name: glob-range-2
   1900 description:
   1901 	Test range matching
   1902 	(AT&T ksh fails this; POSIX says invalid)
   1903 file-setup: file 644 "abc"
   1904 stdin:
   1905 	echo [a--]*
   1906 expected-stdout:
   1907 	[a--]*
   1908 ---
   1909 name: glob-range-3
   1910 description:
   1911 	Check that globbing matches the right things...
   1912 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
   1913 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
   1914 category: !os:cygwin,!os:darwin
   1915 file-setup: file 644 "ac"
   1916 stdin:
   1917 	echo a[-]*
   1918 expected-stdout:
   1919 	ac
   1920 ---
   1921 name: glob-range-4
   1922 description:
   1923 	Results unspecified according to POSIX
   1924 file-setup: file 644 ".bc"
   1925 stdin:
   1926 	echo [a.]*
   1927 expected-stdout:
   1928 	[a.]*
   1929 ---
   1930 name: glob-range-5
   1931 description:
   1932 	Results unspecified according to POSIX
   1933 	(AT&T ksh treats this like [a-cc-e]*)
   1934 file-setup: file 644 "abc"
   1935 file-setup: file 644 "bbc"
   1936 file-setup: file 644 "cbc"
   1937 file-setup: file 644 "dbc"
   1938 file-setup: file 644 "ebc"
   1939 file-setup: file 644 "-bc"
   1940 stdin:
   1941 	echo [a-c-e]*
   1942 expected-stdout:
   1943 	-bc abc bbc cbc ebc
   1944 ---
   1945 name: heredoc-1
   1946 description:
   1947 	Check ordering/content of redundent here documents.
   1948 stdin:
   1949 	cat << EOF1 << EOF2
   1950 	hi
   1951 	EOF1
   1952 	there
   1953 	EOF2
   1954 expected-stdout:
   1955 	there
   1956 ---
   1957 name: heredoc-2
   1958 description:
   1959 	Check quoted here-doc is protected.
   1960 stdin:
   1961 	a=foo
   1962 	cat << 'EOF'
   1963 	hi\
   1964 	there$a
   1965 	stuff
   1966 	EO\
   1967 	F
   1968 	EOF
   1969 expected-stdout:
   1970 	hi\
   1971 	there$a
   1972 	stuff
   1973 	EO\
   1974 	F
   1975 ---
   1976 name: heredoc-3
   1977 description:
   1978 	Check that newline isn't needed after heredoc-delimiter marker.
   1979 stdin: !
   1980 	cat << EOF
   1981 	hi
   1982 	there
   1983 	EOF
   1984 expected-stdout:
   1985 	hi
   1986 	there
   1987 ---
   1988 name: heredoc-4
   1989 description:
   1990 	Check that an error occurs if the heredoc-delimiter is missing.
   1991 stdin: !
   1992 	cat << EOF
   1993 	hi
   1994 	there
   1995 expected-exit: e > 0
   1996 expected-stderr-pattern: /.*/
   1997 ---
   1998 name: heredoc-5
   1999 description:
   2000 	Check that backslash quotes a $, ` and \ and kills a \newline
   2001 stdin:
   2002 	a=BAD
   2003 	b=ok
   2004 	cat << EOF
   2005 	h\${a}i
   2006 	h\\${b}i
   2007 	th\`echo not-run\`ere
   2008 	th\\`echo is-run`ere
   2009 	fol\\ks
   2010 	more\\
   2011 	last \
   2012 	line
   2013 	EOF
   2014 expected-stdout:
   2015 	h${a}i
   2016 	h\oki
   2017 	th`echo not-run`ere
   2018 	th\is-runere
   2019 	fol\ks
   2020 	more\
   2021 	last line
   2022 ---
   2023 name: heredoc-6
   2024 description:
   2025 	Check that \newline in initial here-delim word doesn't imply
   2026 	a quoted here-doc.
   2027 stdin:
   2028 	a=i
   2029 	cat << EO\
   2030 	F
   2031 	h$a
   2032 	there
   2033 	EOF
   2034 expected-stdout:
   2035 	hi
   2036 	there
   2037 ---
   2038 name: heredoc-7
   2039 description:
   2040 	Check that double quoted $ expressions in here delimiters are
   2041 	not expanded and match the delimiter.
   2042 	POSIX says only quote removal is applied to the delimiter.
   2043 stdin:
   2044 	a=b
   2045 	cat << "E$a"
   2046 	hi
   2047 	h$a
   2048 	hb
   2049 	E$a
   2050 	echo done
   2051 expected-stdout:
   2052 	hi
   2053 	h$a
   2054 	hb
   2055 	done
   2056 ---
   2057 name: heredoc-8
   2058 description:
   2059 	Check that double quoted escaped $ expressions in here
   2060 	delimiters are not expanded and match the delimiter.
   2061 	POSIX says only quote removal is applied to the delimiter
   2062 	(\ counts as a quote).
   2063 stdin:
   2064 	a=b
   2065 	cat << "E\$a"
   2066 	hi
   2067 	h$a
   2068 	h\$a
   2069 	hb
   2070 	h\b
   2071 	E$a
   2072 	echo done
   2073 expected-stdout:
   2074 	hi
   2075 	h$a
   2076 	h\$a
   2077 	hb
   2078 	h\b
   2079 	done
   2080 ---
   2081 name: heredoc-9a
   2082 description:
   2083 	Check that here strings work.
   2084 stdin:
   2085 	bar="bar
   2086 		baz"
   2087 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
   2088 	"$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
   2089 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
   2090 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
   2091 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
   2092 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
   2093 expected-stdout:
   2094 	sbb
   2095 	sbb
   2096 	one
   2097 		onm
   2098 	$one
   2099 	$one
   2100 	-sbb
   2101 ---
   2102 name: heredoc-9b
   2103 description:
   2104 	Check that a corner case of here strings works like bash
   2105 stdin:
   2106 	fnord=42
   2107 	bar="bar
   2108 		 \$fnord baz"
   2109 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
   2110 expected-stdout:
   2111 	one $sabeq onm
   2112 category: bash
   2113 ---
   2114 name: heredoc-9c
   2115 description:
   2116 	Check that a corner case of here strings works like ksh93, zsh
   2117 stdin:
   2118 	fnord=42
   2119 	bar="bar
   2120 		 \$fnord baz"
   2121 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
   2122 expected-stdout:
   2123 	one
   2124 		 $sabeq onm
   2125 ---
   2126 name: heredoc-9d
   2127 description:
   2128 	Check another corner case of here strings
   2129 stdin:
   2130 	tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
   2131 expected-stdout:
   2132 	one
   2133 ---
   2134 name: heredoc-9e
   2135 description:
   2136 	Check here string related regression with multiple iops
   2137 stdin:
   2138 	echo $(tr r z <<<'bar' 2>&-)
   2139 expected-stdout:
   2140 	baz
   2141 ---
   2142 name: heredoc-10
   2143 description:
   2144 	Check direct here document assignment
   2145 stdin:
   2146 	x=u
   2147 	va=<<EOF
   2148 	=a $x \x40=
   2149 	EOF
   2150 	vb=<<'EOF'
   2151 	=b $x \x40=
   2152 	EOF
   2153 	function foo {
   2154 		vc=<<-EOF
   2155 			=c $x \x40=
   2156 		EOF
   2157 	}
   2158 	typeset -f foo
   2159 	foo
   2160 	# rather nonsensical, but
   2161 	vd=<<<"=d $x \x40="
   2162 	ve=<<<'=e $x \x40='
   2163 	vf=<<<$'=f $x \x40='
   2164 	# now check
   2165 	print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
   2166 expected-stdout:
   2167 	function foo {
   2168 		vc= <<-EOF 
   2169 	=c $x \x40=
   2170 	EOF
   2171 	
   2172 	} 
   2173 	| va={=a u \x40=
   2174 	} vb={=b $x \x40=
   2175 	} vc={=c u \x40=
   2176 	} vd={=d u \x40=
   2177 	} ve={=e $x \x40=
   2178 	} vf={=f $x @=
   2179 	} |
   2180 ---
   2181 name: heredoc-11
   2182 description:
   2183 	Check here documents with no or empty delimiter
   2184 stdin:
   2185 	x=u
   2186 	va=<<
   2187 	=a $x \x40=
   2188 	<<
   2189 	vb=<<''
   2190 	=b $x \x40=
   2191 	
   2192 	function foo {
   2193 		vc=<<-
   2194 			=c $x \x40=
   2195 		<<
   2196 		vd=<<-''
   2197 			=d $x \x40=
   2198 	
   2199 	}
   2200 	typeset -f foo
   2201 	foo
   2202 	print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
   2203 expected-stdout:
   2204 	function foo {
   2205 		vc= <<- 
   2206 	=c $x \x40=
   2207 	<<
   2208 	
   2209 		vd= <<-"" 
   2210 	=d $x \x40=
   2211 	
   2212 	
   2213 	} 
   2214 	| va={=a u \x40=
   2215 	} vb={=b $x \x40=
   2216 	} vc={=c u \x40=
   2217 	} vd={=d $x \x40=
   2218 	} |
   2219 ---
   2220 name: heredoc-comsub-1
   2221 description:
   2222 	Tests for here documents in COMSUB, taken from Austin ML
   2223 stdin:
   2224 	text=$(cat <<EOF
   2225 	here is the text
   2226 	EOF)
   2227 	echo = $text =
   2228 expected-stdout:
   2229 	= here is the text =
   2230 ---
   2231 name: heredoc-comsub-2
   2232 description:
   2233 	Tests for here documents in COMSUB, taken from Austin ML
   2234 stdin:
   2235 	unbalanced=$(cat <<EOF
   2236 	this paren ) is a problem
   2237 	EOF)
   2238 	echo = $unbalanced =
   2239 expected-stdout:
   2240 	= this paren ) is a problem =
   2241 ---
   2242 name: heredoc-comsub-3
   2243 description:
   2244 	Tests for here documents in COMSUB, taken from Austin ML
   2245 stdin:
   2246 	balanced=$(cat <<EOF
   2247 	these parens ( ) are not a problem
   2248 	EOF)
   2249 	echo = $balanced =
   2250 expected-stdout:
   2251 	= these parens ( ) are not a problem =
   2252 ---
   2253 name: heredoc-comsub-4
   2254 description:
   2255 	Tests for here documents in COMSUB, taken from Austin ML
   2256 stdin:
   2257 	balanced=$(cat <<EOF
   2258 	these parens \( ) are a problem
   2259 	EOF)
   2260 	echo = $balanced =
   2261 expected-stdout:
   2262 	= these parens \( ) are a problem =
   2263 ---
   2264 name: heredoc-subshell-1
   2265 description:
   2266 	Tests for here documents in subshells, taken from Austin ML
   2267 stdin:
   2268 	(cat <<EOF
   2269 	some text
   2270 	EOF)
   2271 	echo end
   2272 expected-stdout:
   2273 	some text
   2274 	end
   2275 ---
   2276 name: heredoc-subshell-2
   2277 description:
   2278 	Tests for here documents in subshells, taken from Austin ML
   2279 stdin:
   2280 	(cat <<EOF
   2281 	some text
   2282 	EOF
   2283 	)
   2284 	echo end
   2285 expected-stdout:
   2286 	some text
   2287 	end
   2288 ---
   2289 name: heredoc-subshell-3
   2290 description:
   2291 	Tests for here documents in subshells, taken from Austin ML
   2292 stdin:
   2293 	(cat <<EOF; )
   2294 	some text
   2295 	EOF
   2296 	echo end
   2297 expected-stdout:
   2298 	some text
   2299 	end
   2300 ---
   2301 name: heredoc-weird-1
   2302 description:
   2303 	Tests for here documents, taken from Austin ML
   2304 	Documents current state in mksh, *NOT* necessarily correct!
   2305 stdin:
   2306 	cat <<END
   2307 	hello
   2308 	END\
   2309 	END
   2310 	END
   2311 	echo end
   2312 expected-stdout:
   2313 	hello
   2314 	ENDEND
   2315 	end
   2316 ---
   2317 name: heredoc-weird-2
   2318 description:
   2319 	Tests for here documents, taken from Austin ML
   2320 stdin:
   2321 	cat <<'    END    '
   2322 	hello
   2323 	    END    
   2324 	echo end
   2325 expected-stdout:
   2326 	hello
   2327 	end
   2328 ---
   2329 name: heredoc-weird-4
   2330 description:
   2331 	Tests for here documents, taken from Austin ML
   2332 	Documents current state in mksh, *NOT* necessarily correct!
   2333 stdin:
   2334 	cat <<END
   2335 	hello\
   2336 	END
   2337 	END
   2338 	echo end
   2339 expected-stdout:
   2340 	helloEND
   2341 	end
   2342 ---
   2343 name: heredoc-weird-5
   2344 description:
   2345 	Tests for here documents, taken from Austin ML
   2346 	Documents current state in mksh, *NOT* necessarily correct!
   2347 stdin:
   2348 	cat <<END
   2349 	hello
   2350 	\END
   2351 	END
   2352 	echo end
   2353 expected-stdout:
   2354 	hello
   2355 	\END
   2356 	end
   2357 ---
   2358 name: heredoc-quoting-unsubst
   2359 description:
   2360 	Check for correct handling of quoted characters in
   2361 	here documents without substitution (marker is quoted).
   2362 stdin:
   2363 	foo=bar
   2364 	cat <<-'EOF'
   2365 		x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
   2366 	EOF
   2367 expected-stdout:
   2368 	x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
   2369 ---
   2370 name: heredoc-quoting-subst
   2371 description:
   2372 	Check for correct handling of quoted characters in
   2373 	here documents with substitution (marker is not quoted).
   2374 stdin:
   2375 	foo=bar
   2376 	cat <<-EOF
   2377 		x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
   2378 	EOF
   2379 expected-stdout:
   2380 	x " \" \ \ $ $ baz `echo baz` bar $foo x
   2381 ---
   2382 name: heredoc-tmpfile-1
   2383 description:
   2384 	Check that heredoc temp files aren't removed too soon or too late.
   2385 	Heredoc in simple command.
   2386 stdin:
   2387 	TMPDIR=$PWD
   2388 	eval '
   2389 		cat <<- EOF
   2390 		hi
   2391 		EOF
   2392 		for i in a b ; do
   2393 			cat <<- EOF
   2394 			more
   2395 			EOF
   2396 		done
   2397 	    ' &
   2398 	sleep 1
   2399 	echo Left overs: *
   2400 expected-stdout:
   2401 	hi
   2402 	more
   2403 	more
   2404 	Left overs: *
   2405 ---
   2406 name: heredoc-tmpfile-2
   2407 description:
   2408 	Check that heredoc temp files aren't removed too soon or too late.
   2409 	Heredoc in function, multiple calls to function.
   2410 stdin:
   2411 	TMPDIR=$PWD
   2412 	eval '
   2413 		foo() {
   2414 			cat <<- EOF
   2415 			hi
   2416 			EOF
   2417 		}
   2418 		foo
   2419 		foo
   2420 	    ' &
   2421 	sleep 1
   2422 	echo Left overs: *
   2423 expected-stdout:
   2424 	hi
   2425 	hi
   2426 	Left overs: *
   2427 ---
   2428 name: heredoc-tmpfile-3
   2429 description:
   2430 	Check that heredoc temp files aren't removed too soon or too late.
   2431 	Heredoc in function in loop, multiple calls to function.
   2432 stdin:
   2433 	TMPDIR=$PWD
   2434 	eval '
   2435 		foo() {
   2436 			cat <<- EOF
   2437 			hi
   2438 			EOF
   2439 		}
   2440 		for i in a b; do
   2441 			foo
   2442 			foo() {
   2443 				cat <<- EOF
   2444 				folks $i
   2445 				EOF
   2446 			}
   2447 		done
   2448 		foo
   2449 	    ' &
   2450 	sleep 1
   2451 	echo Left overs: *
   2452 expected-stdout:
   2453 	hi
   2454 	folks b
   2455 	folks b
   2456 	Left overs: *
   2457 ---
   2458 name: heredoc-tmpfile-4
   2459 description:
   2460 	Check that heredoc temp files aren't removed too soon or too late.
   2461 	Backgrounded simple command with here doc
   2462 stdin:
   2463 	TMPDIR=$PWD
   2464 	eval '
   2465 		cat <<- EOF &
   2466 		hi
   2467 		EOF
   2468 	    ' &
   2469 	sleep 1
   2470 	echo Left overs: *
   2471 expected-stdout:
   2472 	hi
   2473 	Left overs: *
   2474 ---
   2475 name: heredoc-tmpfile-5
   2476 description:
   2477 	Check that heredoc temp files aren't removed too soon or too late.
   2478 	Backgrounded subshell command with here doc
   2479 stdin:
   2480 	TMPDIR=$PWD
   2481 	eval '
   2482 	      (
   2483 		sleep 1	# so parent exits
   2484 		echo A
   2485 		cat <<- EOF
   2486 		hi
   2487 		EOF
   2488 		echo B
   2489 	      ) &
   2490 	    ' &
   2491 	sleep 2
   2492 	echo Left overs: *
   2493 expected-stdout:
   2494 	A
   2495 	hi
   2496 	B
   2497 	Left overs: *
   2498 ---
   2499 name: heredoc-tmpfile-6
   2500 description:
   2501 	Check that heredoc temp files aren't removed too soon or too late.
   2502 	Heredoc in pipeline.
   2503 stdin:
   2504 	TMPDIR=$PWD
   2505 	eval '
   2506 		cat <<- EOF | sed "s/hi/HI/"
   2507 		hi
   2508 		EOF
   2509 	    ' &
   2510 	sleep 1
   2511 	echo Left overs: *
   2512 expected-stdout:
   2513 	HI
   2514 	Left overs: *
   2515 ---
   2516 name: heredoc-tmpfile-7
   2517 description:
   2518 	Check that heredoc temp files aren't removed too soon or too late.
   2519 	Heredoc in backgrounded pipeline.
   2520 stdin:
   2521 	TMPDIR=$PWD
   2522 	eval '
   2523 		cat <<- EOF | sed 's/hi/HI/' &
   2524 		hi
   2525 		EOF
   2526 	    ' &
   2527 	sleep 1
   2528 	echo Left overs: *
   2529 expected-stdout:
   2530 	HI
   2531 	Left overs: *
   2532 ---
   2533 name: heredoc-tmpfile-8
   2534 description:
   2535 	Check that heredoc temp files aren't removed too soon or too
   2536 	late. Heredoc in function, backgrounded call to function.
   2537 	This check can fail on slow machines (<100 MHz), or Cygwin,
   2538 	that's normal.
   2539 need-pass: no
   2540 stdin:
   2541 	TMPDIR=$PWD
   2542 	# Background eval so main shell doesn't do parsing
   2543 	eval '
   2544 		foo() {
   2545 			cat <<- EOF
   2546 			hi
   2547 			EOF
   2548 		}
   2549 		foo
   2550 		# sleep so eval can die
   2551 		(sleep 1; foo) &
   2552 		(sleep 1; foo) &
   2553 		foo
   2554 	    ' &
   2555 	sleep 2
   2556 	echo Left overs: *
   2557 expected-stdout:
   2558 	hi
   2559 	hi
   2560 	hi
   2561 	hi
   2562 	Left overs: *
   2563 ---
   2564 name: history-basic
   2565 description:
   2566 	See if we can test history at all
   2567 need-ctty: yes
   2568 arguments: !-i!
   2569 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2570 file-setup: file 644 "Env"
   2571 	PS1=X
   2572 stdin:
   2573 	echo hi
   2574 	fc -l
   2575 expected-stdout:
   2576 	hi
   2577 	1	echo hi
   2578 expected-stderr-pattern:
   2579 	/^X*$/
   2580 ---
   2581 name: history-dups
   2582 description:
   2583 	Verify duplicates and spaces are not entered
   2584 need-ctty: yes
   2585 arguments: !-i!
   2586 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2587 file-setup: file 644 "Env"
   2588 	PS1=X
   2589 stdin:
   2590 	echo hi
   2591 	 echo yo
   2592 	echo hi
   2593 	fc -l
   2594 expected-stdout:
   2595 	hi
   2596 	yo
   2597 	hi
   2598 	1	echo hi
   2599 expected-stderr-pattern:
   2600 	/^X*$/
   2601 ---
   2602 name: history-unlink
   2603 description:
   2604 	Check if broken HISTFILEs do not cause trouble
   2605 need-ctty: yes
   2606 arguments: !-i!
   2607 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
   2608 file-setup: file 644 "Env"
   2609 	PS1=X
   2610 file-setup: dir 755 "foo"
   2611 file-setup: file 644 "foo/hist.file"
   2612 	sometext
   2613 time-limit: 5
   2614 perl-setup: chmod(0555, "foo");
   2615 stdin:
   2616 	echo hi
   2617 	fc -l
   2618 	chmod 0755 foo
   2619 expected-stdout:
   2620 	hi
   2621 	1	echo hi
   2622 expected-stderr-pattern:
   2623 	/(.*can't unlink HISTFILE.*\n)?X*$/
   2624 ---
   2625 name: history-e-minus-1
   2626 description:
   2627 	Check if more recent command is executed
   2628 need-ctty: yes
   2629 arguments: !-i!
   2630 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2631 file-setup: file 644 "Env"
   2632 	PS1=X
   2633 stdin:
   2634 	echo hi
   2635 	echo there
   2636 	fc -e -
   2637 expected-stdout:
   2638 	hi
   2639 	there
   2640 	there
   2641 expected-stderr-pattern:
   2642 	/^X*echo there\nX*$/
   2643 ---
   2644 name: history-e-minus-2
   2645 description:
   2646 	Check that repeated command is printed before command
   2647 	is re-executed.
   2648 need-ctty: yes
   2649 arguments: !-i!
   2650 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2651 file-setup: file 644 "Env"
   2652 	PS1=X
   2653 stdin:
   2654 	exec 2>&1
   2655 	echo hi
   2656 	echo there
   2657 	fc -e -
   2658 expected-stdout-pattern:
   2659 	/X*hi\nX*there\nX*echo there\nthere\nX*/
   2660 expected-stderr-pattern:
   2661 	/^X*$/
   2662 ---
   2663 name: history-e-minus-3
   2664 description:
   2665 	fc -e - fails when there is no history
   2666 	(ksh93 has a bug that causes this to fail)
   2667 	(ksh88 loops on this)
   2668 need-ctty: yes
   2669 arguments: !-i!
   2670 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2671 file-setup: file 644 "Env"
   2672 	PS1=X
   2673 stdin:
   2674 	fc -e -
   2675 	echo ok
   2676 expected-stdout:
   2677 	ok
   2678 expected-stderr-pattern:
   2679 	/^X*.*:.*history.*\nX*$/
   2680 ---
   2681 name: history-e-minus-4
   2682 description:
   2683 	Check if "fc -e -" command output goes to stdout.
   2684 need-ctty: yes
   2685 arguments: !-i!
   2686 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2687 file-setup: file 644 "Env"
   2688 	PS1=X
   2689 stdin:
   2690 	echo abc
   2691 	fc -e - | (read x; echo "A $x")
   2692 	echo ok
   2693 expected-stdout:
   2694 	abc
   2695 	A abc
   2696 	ok
   2697 expected-stderr-pattern:
   2698 	/^X*echo abc\nX*/
   2699 ---
   2700 name: history-e-minus-5
   2701 description:
   2702 	fc is replaced in history by new command.
   2703 need-ctty: yes
   2704 arguments: !-i!
   2705 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2706 file-setup: file 644 "Env"
   2707 	PS1=X
   2708 stdin:
   2709 	echo abc def
   2710 	echo ghi jkl
   2711 	:
   2712 	fc -e - echo
   2713 	fc -l 2 5
   2714 expected-stdout:
   2715 	abc def
   2716 	ghi jkl
   2717 	ghi jkl
   2718 	2	echo ghi jkl
   2719 	3	:
   2720 	4	echo ghi jkl
   2721 	5	fc -l 2 5
   2722 expected-stderr-pattern:
   2723 	/^X*echo ghi jkl\nX*$/
   2724 ---
   2725 name: history-list-1
   2726 description:
   2727 	List lists correct range
   2728 	(ksh88 fails 'cause it lists the fc command)
   2729 need-ctty: yes
   2730 arguments: !-i!
   2731 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2732 file-setup: file 644 "Env"
   2733 	PS1=X
   2734 stdin:
   2735 	echo line 1
   2736 	echo line 2
   2737 	echo line 3
   2738 	fc -l -- -2
   2739 expected-stdout:
   2740 	line 1
   2741 	line 2
   2742 	line 3
   2743 	2	echo line 2
   2744 	3	echo line 3
   2745 expected-stderr-pattern:
   2746 	/^X*$/
   2747 ---
   2748 name: history-list-2
   2749 description:
   2750 	Lists oldest history if given pre-historic number
   2751 	(ksh93 has a bug that causes this to fail)
   2752 	(ksh88 fails 'cause it lists the fc command)
   2753 need-ctty: yes
   2754 arguments: !-i!
   2755 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2756 file-setup: file 644 "Env"
   2757 	PS1=X
   2758 stdin:
   2759 	echo line 1
   2760 	echo line 2
   2761 	echo line 3
   2762 	fc -l -- -40
   2763 expected-stdout:
   2764 	line 1
   2765 	line 2
   2766 	line 3
   2767 	1	echo line 1
   2768 	2	echo line 2
   2769 	3	echo line 3
   2770 expected-stderr-pattern:
   2771 	/^X*$/
   2772 ---
   2773 name: history-list-3
   2774 description:
   2775 	Can give number 'options' to fc
   2776 need-ctty: yes
   2777 arguments: !-i!
   2778 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2779 file-setup: file 644 "Env"
   2780 	PS1=X
   2781 stdin:
   2782 	echo line 1
   2783 	echo line 2
   2784 	echo line 3
   2785 	echo line 4
   2786 	fc -l -3 -2
   2787 expected-stdout:
   2788 	line 1
   2789 	line 2
   2790 	line 3
   2791 	line 4
   2792 	2	echo line 2
   2793 	3	echo line 3
   2794 expected-stderr-pattern:
   2795 	/^X*$/
   2796 ---
   2797 name: history-list-4
   2798 description:
   2799 	-1 refers to previous command
   2800 need-ctty: yes
   2801 arguments: !-i!
   2802 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2803 file-setup: file 644 "Env"
   2804 	PS1=X
   2805 stdin:
   2806 	echo line 1
   2807 	echo line 2
   2808 	echo line 3
   2809 	echo line 4
   2810 	fc -l -1 -1
   2811 expected-stdout:
   2812 	line 1
   2813 	line 2
   2814 	line 3
   2815 	line 4
   2816 	4	echo line 4
   2817 expected-stderr-pattern:
   2818 	/^X*$/
   2819 ---
   2820 name: history-list-5
   2821 description:
   2822 	List command stays in history
   2823 need-ctty: yes
   2824 arguments: !-i!
   2825 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2826 file-setup: file 644 "Env"
   2827 	PS1=X
   2828 stdin:
   2829 	echo line 1
   2830 	echo line 2
   2831 	echo line 3
   2832 	echo line 4
   2833 	fc -l -1 -1
   2834 	fc -l -2 -1
   2835 expected-stdout:
   2836 	line 1
   2837 	line 2
   2838 	line 3
   2839 	line 4
   2840 	4	echo line 4
   2841 	4	echo line 4
   2842 	5	fc -l -1 -1
   2843 expected-stderr-pattern:
   2844 	/^X*$/
   2845 ---
   2846 name: history-list-6
   2847 description:
   2848 	HISTSIZE limits about of history kept.
   2849 	(ksh88 fails 'cause it lists the fc command)
   2850 need-ctty: yes
   2851 arguments: !-i!
   2852 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
   2853 file-setup: file 644 "Env"
   2854 	PS1=X
   2855 stdin:
   2856 	echo line 1
   2857 	echo line 2
   2858 	echo line 3
   2859 	echo line 4
   2860 	echo line 5
   2861 	fc -l
   2862 expected-stdout:
   2863 	line 1
   2864 	line 2
   2865 	line 3
   2866 	line 4
   2867 	line 5
   2868 	4	echo line 4
   2869 	5	echo line 5
   2870 expected-stderr-pattern:
   2871 	/^X*$/
   2872 ---
   2873 name: history-list-7
   2874 description:
   2875 	fc allows too old/new errors in range specification
   2876 need-ctty: yes
   2877 arguments: !-i!
   2878 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
   2879 file-setup: file 644 "Env"
   2880 	PS1=X
   2881 stdin:
   2882 	echo line 1
   2883 	echo line 2
   2884 	echo line 3
   2885 	echo line 4
   2886 	echo line 5
   2887 	fc -l 1 30
   2888 expected-stdout:
   2889 	line 1
   2890 	line 2
   2891 	line 3
   2892 	line 4
   2893 	line 5
   2894 	4	echo line 4
   2895 	5	echo line 5
   2896 	6	fc -l 1 30
   2897 expected-stderr-pattern:
   2898 	/^X*$/
   2899 ---
   2900 name: history-list-r-1
   2901 description:
   2902 	test -r flag in history
   2903 need-ctty: yes
   2904 arguments: !-i!
   2905 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2906 file-setup: file 644 "Env"
   2907 	PS1=X
   2908 stdin:
   2909 	echo line 1
   2910 	echo line 2
   2911 	echo line 3
   2912 	echo line 4
   2913 	echo line 5
   2914 	fc -l -r 2 4
   2915 expected-stdout:
   2916 	line 1
   2917 	line 2
   2918 	line 3
   2919 	line 4
   2920 	line 5
   2921 	4	echo line 4
   2922 	3	echo line 3
   2923 	2	echo line 2
   2924 expected-stderr-pattern:
   2925 	/^X*$/
   2926 ---
   2927 name: history-list-r-2
   2928 description:
   2929 	If first is newer than last, -r is implied.
   2930 need-ctty: yes
   2931 arguments: !-i!
   2932 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2933 file-setup: file 644 "Env"
   2934 	PS1=X
   2935 stdin:
   2936 	echo line 1
   2937 	echo line 2
   2938 	echo line 3
   2939 	echo line 4
   2940 	echo line 5
   2941 	fc -l 4 2
   2942 expected-stdout:
   2943 	line 1
   2944 	line 2
   2945 	line 3
   2946 	line 4
   2947 	line 5
   2948 	4	echo line 4
   2949 	3	echo line 3
   2950 	2	echo line 2
   2951 expected-stderr-pattern:
   2952 	/^X*$/
   2953 ---
   2954 name: history-list-r-3
   2955 description:
   2956 	If first is newer than last, -r is cancelled.
   2957 need-ctty: yes
   2958 arguments: !-i!
   2959 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2960 file-setup: file 644 "Env"
   2961 	PS1=X
   2962 stdin:
   2963 	echo line 1
   2964 	echo line 2
   2965 	echo line 3
   2966 	echo line 4
   2967 	echo line 5
   2968 	fc -l -r 4 2
   2969 expected-stdout:
   2970 	line 1
   2971 	line 2
   2972 	line 3
   2973 	line 4
   2974 	line 5
   2975 	2	echo line 2
   2976 	3	echo line 3
   2977 	4	echo line 4
   2978 expected-stderr-pattern:
   2979 	/^X*$/
   2980 ---
   2981 name: history-subst-1
   2982 description:
   2983 	Basic substitution
   2984 need-ctty: yes
   2985 arguments: !-i!
   2986 env-setup: !ENV=./Env!HISTFILE=hist.file!
   2987 file-setup: file 644 "Env"
   2988 	PS1=X
   2989 stdin:
   2990 	echo abc def
   2991 	echo ghi jkl
   2992 	fc -e - abc=AB 'echo a'
   2993 expected-stdout:
   2994 	abc def
   2995 	ghi jkl
   2996 	AB def
   2997 expected-stderr-pattern:
   2998 	/^X*echo AB def\nX*$/
   2999 ---
   3000 name: history-subst-2
   3001 description:
   3002 	Does subst find previous command?
   3003 need-ctty: yes
   3004 arguments: !-i!
   3005 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3006 file-setup: file 644 "Env"
   3007 	PS1=X
   3008 stdin:
   3009 	echo abc def
   3010 	echo ghi jkl
   3011 	fc -e - jkl=XYZQRT 'echo g'
   3012 expected-stdout:
   3013 	abc def
   3014 	ghi jkl
   3015 	ghi XYZQRT
   3016 expected-stderr-pattern:
   3017 	/^X*echo ghi XYZQRT\nX*$/
   3018 ---
   3019 name: history-subst-3
   3020 description:
   3021 	Does subst find previous command when no arguments given
   3022 need-ctty: yes
   3023 arguments: !-i!
   3024 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3025 file-setup: file 644 "Env"
   3026 	PS1=X
   3027 stdin:
   3028 	echo abc def
   3029 	echo ghi jkl
   3030 	fc -e - jkl=XYZQRT
   3031 expected-stdout:
   3032 	abc def
   3033 	ghi jkl
   3034 	ghi XYZQRT
   3035 expected-stderr-pattern:
   3036 	/^X*echo ghi XYZQRT\nX*$/
   3037 ---
   3038 name: history-subst-4
   3039 description:
   3040 	Global substitutions work
   3041 	(ksh88 and ksh93 do not have -g option)
   3042 need-ctty: yes
   3043 arguments: !-i!
   3044 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3045 file-setup: file 644 "Env"
   3046 	PS1=X
   3047 stdin:
   3048 	echo abc def asjj sadjhasdjh asdjhasd
   3049 	fc -e - -g a=FooBAR
   3050 expected-stdout:
   3051 	abc def asjj sadjhasdjh asdjhasd
   3052 	FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
   3053 expected-stderr-pattern:
   3054 	/^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
   3055 ---
   3056 name: history-subst-5
   3057 description:
   3058 	Make sure searches don't find current (fc) command
   3059 	(ksh88/ksh93 don't have the ? prefix thing so they fail this test)
   3060 need-ctty: yes
   3061 arguments: !-i!
   3062 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3063 file-setup: file 644 "Env"
   3064 	PS1=X
   3065 stdin:
   3066 	echo abc def
   3067 	echo ghi jkl
   3068 	fc -e - abc=AB \?abc
   3069 expected-stdout:
   3070 	abc def
   3071 	ghi jkl
   3072 	AB def
   3073 expected-stderr-pattern:
   3074 	/^X*echo AB def\nX*$/
   3075 ---
   3076 name: history-ed-1-old
   3077 description:
   3078 	Basic (ed) editing works (assumes you have generic ed editor
   3079 	that prints no prompts). This is for oldish ed(1) which write
   3080 	the character count to stdout.
   3081 category: stdout-ed
   3082 need-ctty: yes
   3083 need-pass: no
   3084 arguments: !-i!
   3085 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3086 file-setup: file 644 "Env"
   3087 	PS1=X
   3088 stdin:
   3089 	echo abc def
   3090 	fc echo
   3091 	s/abc/FOOBAR/
   3092 	w
   3093 	q
   3094 expected-stdout:
   3095 	abc def
   3096 	13
   3097 	16
   3098 	FOOBAR def
   3099 expected-stderr-pattern:
   3100 	/^X*echo FOOBAR def\nX*$/
   3101 ---
   3102 name: history-ed-2-old
   3103 description:
   3104 	Correct command is edited when number given
   3105 category: stdout-ed
   3106 need-ctty: yes
   3107 need-pass: no
   3108 arguments: !-i!
   3109 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3110 file-setup: file 644 "Env"
   3111 	PS1=X
   3112 stdin:
   3113 	echo line 1
   3114 	echo line 2 is here
   3115 	echo line 3
   3116 	echo line 4
   3117 	fc 2
   3118 	s/is here/is changed/
   3119 	w
   3120 	q
   3121 expected-stdout:
   3122 	line 1
   3123 	line 2 is here
   3124 	line 3
   3125 	line 4
   3126 	20
   3127 	23
   3128 	line 2 is changed
   3129 expected-stderr-pattern:
   3130 	/^X*echo line 2 is changed\nX*$/
   3131 ---
   3132 name: history-ed-3-old
   3133 description:
   3134 	Newly created multi line commands show up as single command
   3135 	in history.
   3136 	(NOTE: adjusted for COMPLEX HISTORY compile time option)
   3137 	(ksh88 fails 'cause it lists the fc command)
   3138 category: stdout-ed
   3139 need-ctty: yes
   3140 need-pass: no
   3141 arguments: !-i!
   3142 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3143 file-setup: file 644 "Env"
   3144 	PS1=X
   3145 stdin:
   3146 	echo abc def
   3147 	fc echo
   3148 	s/abc/FOOBAR/
   3149 	$a
   3150 	echo a new line
   3151 	.
   3152 	w
   3153 	q
   3154 	fc -l
   3155 expected-stdout:
   3156 	abc def
   3157 	13
   3158 	32
   3159 	FOOBAR def
   3160 	a new line
   3161 	1	echo abc def
   3162 	2	echo FOOBAR def
   3163 	3	echo a new line
   3164 expected-stderr-pattern:
   3165 	/^X*echo FOOBAR def\necho a new line\nX*$/
   3166 ---
   3167 name: history-ed-1
   3168 description:
   3169 	Basic (ed) editing works (assumes you have generic ed editor
   3170 	that prints no prompts). This is for newish ed(1) and stderr.
   3171 category: !no-stderr-ed
   3172 need-ctty: yes
   3173 need-pass: no
   3174 arguments: !-i!
   3175 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3176 file-setup: file 644 "Env"
   3177 	PS1=X
   3178 stdin:
   3179 	echo abc def
   3180 	fc echo
   3181 	s/abc/FOOBAR/
   3182 	w
   3183 	q
   3184 expected-stdout:
   3185 	abc def
   3186 	FOOBAR def
   3187 expected-stderr-pattern:
   3188 	/^X*13\n16\necho FOOBAR def\nX*$/
   3189 ---
   3190 name: history-ed-2
   3191 description:
   3192 	Correct command is edited when number given
   3193 category: !no-stderr-ed
   3194 need-ctty: yes
   3195 need-pass: no
   3196 arguments: !-i!
   3197 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3198 file-setup: file 644 "Env"
   3199 	PS1=X
   3200 stdin:
   3201 	echo line 1
   3202 	echo line 2 is here
   3203 	echo line 3
   3204 	echo line 4
   3205 	fc 2
   3206 	s/is here/is changed/
   3207 	w
   3208 	q
   3209 expected-stdout:
   3210 	line 1
   3211 	line 2 is here
   3212 	line 3
   3213 	line 4
   3214 	line 2 is changed
   3215 expected-stderr-pattern:
   3216 	/^X*20\n23\necho line 2 is changed\nX*$/
   3217 ---
   3218 name: history-ed-3
   3219 description:
   3220 	Newly created multi line commands show up as single command
   3221 	in history.
   3222 category: !no-stderr-ed
   3223 need-ctty: yes
   3224 need-pass: no
   3225 arguments: !-i!
   3226 env-setup: !ENV=./Env!HISTFILE=hist.file!
   3227 file-setup: file 644 "Env"
   3228 	PS1=X
   3229 stdin:
   3230 	echo abc def
   3231 	fc echo
   3232 	s/abc/FOOBAR/
   3233 	$a
   3234 	echo a new line
   3235 	.
   3236 	w
   3237 	q
   3238 	fc -l
   3239 expected-stdout:
   3240 	abc def
   3241 	FOOBAR def
   3242 	a new line
   3243 	1	echo abc def
   3244 	2	echo FOOBAR def
   3245 	3	echo a new line
   3246 expected-stderr-pattern:
   3247 	/^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
   3248 ---
   3249 name: IFS-space-1
   3250 description:
   3251 	Simple test, default IFS
   3252 stdin:
   3253 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3254 	set -- A B C
   3255 	showargs 1 $*
   3256 	showargs 2 "$*"
   3257 	showargs 3 $@
   3258 	showargs 4 "$@"
   3259 expected-stdout:
   3260 	 <1> <A> <B> <C>
   3261 	 <2> <A B C>
   3262 	 <3> <A> <B> <C>
   3263 	 <4> <A> <B> <C>
   3264 ---
   3265 name: IFS-colon-1
   3266 description:
   3267 	Simple test, IFS=:
   3268 stdin:
   3269 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3270 	IFS=:
   3271 	set -- A B C
   3272 	showargs 1 $*
   3273 	showargs 2 "$*"
   3274 	showargs 3 $@
   3275 	showargs 4 "$@"
   3276 expected-stdout:
   3277 	 <1> <A> <B> <C>
   3278 	 <2> <A:B:C>
   3279 	 <3> <A> <B> <C>
   3280 	 <4> <A> <B> <C>
   3281 ---
   3282 name: IFS-null-1
   3283 description:
   3284 	Simple test, IFS=""
   3285 stdin:
   3286 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3287 	IFS=""
   3288 	set -- A B C
   3289 	showargs 1 $*
   3290 	showargs 2 "$*"
   3291 	showargs 3 $@
   3292 	showargs 4 "$@"
   3293 expected-stdout:
   3294 	 <1> <A B C>
   3295 	 <2> <ABC>
   3296 	 <3> <A B C>
   3297 	 <4> <A B C>
   3298 ---
   3299 name: IFS-space-colon-1
   3300 description:
   3301 	Simple test, IFS=<white-space>:
   3302 stdin:
   3303 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3304 	IFS="$IFS:"
   3305 	set --
   3306 	showargs 1 $*
   3307 	showargs 2 "$*"
   3308 	showargs 3 $@
   3309 	showargs 4 "$@"
   3310 	showargs 5 : "$@"
   3311 expected-stdout:
   3312 	 <1>
   3313 	 <2> <>
   3314 	 <3>
   3315 	 <4>
   3316 	 <5> <:>
   3317 ---
   3318 name: IFS-space-colon-2
   3319 description:
   3320 	Simple test, IFS=<white-space>:
   3321 	AT&T ksh fails this, POSIX says the test is correct.
   3322 stdin:
   3323 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3324 	IFS="$IFS:"
   3325 	set --
   3326 	showargs :"$@"
   3327 expected-stdout:
   3328 	 <:>
   3329 ---
   3330 name: IFS-space-colon-4
   3331 description:
   3332 	Simple test, IFS=<white-space>:
   3333 stdin:
   3334 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3335 	IFS="$IFS:"
   3336 	set --
   3337 	showargs "$@$@"
   3338 expected-stdout:
   3339 	
   3340 ---
   3341 name: IFS-space-colon-5
   3342 description:
   3343 	Simple test, IFS=<white-space>:
   3344 	Don't know what POSIX thinks of this.  AT&T ksh does not do this.
   3345 stdin:
   3346 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3347 	IFS="$IFS:"
   3348 	set --
   3349 	showargs "${@:-}"
   3350 expected-stdout:
   3351 	 <>
   3352 ---
   3353 name: IFS-subst-1
   3354 description:
   3355 	Simple test, IFS=<white-space>:
   3356 stdin:
   3357 	showargs() { for i; do echo -n " <$i>"; done; echo; }
   3358 	IFS="$IFS:"
   3359 	x=":b: :"
   3360 	echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
   3361 	echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
   3362 	showargs 3 $x
   3363 	showargs 4 :b::
   3364 	x="a:b:"
   3365 	echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
   3366 	showargs 6 $x
   3367 	x="a::c"
   3368 	echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
   3369 	showargs 8 $x
   3370 	echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
   3371 	showargs 10 ${FOO-`echo -n h:i`th:ere}
   3372 	showargs 11 "${FOO-`echo -n h:i`th:ere}"
   3373 	x=" A :  B::D"
   3374 	echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
   3375 	showargs 13 $x
   3376 expected-stdout:
   3377 	1: [] [b] []
   3378 	2: [:b::]
   3379 	 <3> <> <b> <>
   3380 	 <4> <:b::>
   3381 	5: [a] [b]
   3382 	 <6> <a> <b>
   3383 	7: [a] [] [c]
   3384 	 <8> <a> <> <c>
   3385 	9: [h] [ith] [ere]
   3386 	 <10> <h> <ith> <ere>
   3387 	 <11> <h:ith:ere>
   3388 	12: [A] [B] [] [D]
   3389 	 <13> <A> <B> <> <D>
   3390 ---
   3391 name: integer-base-err-1
   3392 description:
   3393 	Can't have 0 base (causes shell to exit)
   3394 expected-exit: e != 0
   3395 stdin:
   3396 	typeset -i i
   3397 	i=3
   3398 	i=0#4
   3399 	echo $i
   3400 expected-stderr-pattern:
   3401 	/^.*:.*0#4.*\n$/
   3402 ---
   3403 name: integer-base-err-2
   3404 description:
   3405 	Can't have multiple bases in a 'constant' (causes shell to exit)
   3406 	(ksh88 fails this test)
   3407 expected-exit: e != 0
   3408 stdin:
   3409 	typeset -i i
   3410 	i=3
   3411 	i=2#110#11
   3412 	echo $i
   3413 expected-stderr-pattern:
   3414 	/^.*:.*2#110#11.*\n$/
   3415 ---
   3416 name: integer-base-err-3
   3417 description:
   3418 	Syntax errors in expressions and effects on bases
   3419 	(interactive so errors don't cause exits)
   3420 	(ksh88 fails this test - shell exits, even with -i)
   3421 need-ctty: yes
   3422 arguments: !-i!
   3423 stdin:
   3424 	PS1= # minimise prompt hassles
   3425 	typeset -i4 a=10
   3426 	typeset -i a=2+
   3427 	echo $a
   3428 	typeset -i4 a=10
   3429 	typeset -i2 a=2+
   3430 	echo $a
   3431 expected-stderr-pattern:
   3432 	/^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
   3433 expected-stdout:
   3434 	4#22
   3435 	4#22
   3436 ---
   3437 name: integer-base-err-4
   3438 description:
   3439 	Are invalid digits (according to base) errors?
   3440 	(ksh93 fails this test)
   3441 expected-exit: e != 0
   3442 stdin:
   3443 	typeset -i i;
   3444 	i=3#4
   3445 expected-stderr-pattern:
   3446 	/^([#\$] )?.*:.*3#4.*\n$/
   3447 ---
   3448 name: integer-base-1
   3449 description:
   3450 	Missing number after base is treated as 0.
   3451 stdin:
   3452 	typeset -i i
   3453 	i=3
   3454 	i=2#
   3455 	echo $i
   3456 expected-stdout:
   3457 	0
   3458 ---
   3459 name: integer-base-2
   3460 description:
   3461 	Check 'stickyness' of base in various situations
   3462 stdin:
   3463 	typeset -i i=8
   3464 	echo $i
   3465 	echo ---------- A
   3466 	typeset -i4 j=8
   3467 	echo $j
   3468 	echo ---------- B
   3469 	typeset -i k=8
   3470 	typeset -i4 k=8
   3471 	echo $k
   3472 	echo ---------- C
   3473 	typeset -i4 l
   3474 	l=3#10
   3475 	echo $l
   3476 	echo ---------- D
   3477 	typeset -i m
   3478 	m=3#10
   3479 	echo $m
   3480 	echo ---------- E
   3481 	n=2#11
   3482 	typeset -i n
   3483 	echo $n
   3484 	n=10
   3485 	echo $n
   3486 	echo ---------- F
   3487 	typeset -i8 o=12
   3488 	typeset -i4 o
   3489 	echo $o
   3490 	echo ---------- G
   3491 	typeset -i p
   3492 	let p=8#12
   3493 	echo $p
   3494 expected-stdout:
   3495 	8
   3496 	---------- A
   3497 	4#20
   3498 	---------- B
   3499 	4#20
   3500 	---------- C
   3501 	4#3
   3502 	---------- D
   3503 	3#10
   3504 	---------- E
   3505 	2#11
   3506 	2#1010
   3507 	---------- F
   3508 	4#30
   3509 	---------- G
   3510 	8#12
   3511 ---
   3512 name: integer-base-3
   3513 description:
   3514 	More base parsing (hmm doesn't test much..)
   3515 stdin:
   3516 	typeset -i aa
   3517 	aa=1+12#10+2
   3518 	echo $aa
   3519 	typeset -i bb
   3520 	bb=1+$aa
   3521 	echo $bb
   3522 	typeset -i bb
   3523 	bb=$aa
   3524 	echo $bb
   3525 	typeset -i cc
   3526 	cc=$aa
   3527 	echo $cc
   3528 expected-stdout:
   3529 	15
   3530 	16
   3531 	15
   3532 	15
   3533 ---
   3534 name: integer-base-4
   3535 description:
   3536 	Check that things not declared as integers are not made integers,
   3537 	also, check if base is not reset by -i with no arguments.
   3538 	(ksh93 fails - prints 10#20 - go figure)
   3539 stdin:
   3540 	xx=20
   3541 	let xx=10
   3542 	typeset -i | grep '^xx='
   3543 	typeset -i4 a=10
   3544 	typeset -i a=20
   3545 	echo $a
   3546 expected-stdout:
   3547 	4#110
   3548 ---
   3549 name: integer-base-5
   3550 description:
   3551 	More base stuff
   3552 stdin:
   3553 	typeset -i4 a=3#10
   3554 	echo $a
   3555 	echo --
   3556 	typeset -i j=3
   3557 	j='~3'
   3558 	echo $j
   3559 	echo --
   3560 	typeset -i k=1
   3561 	x[k=k+1]=3
   3562 	echo $k
   3563 	echo --
   3564 	typeset -i l
   3565 	for l in 1 2+3 4; do echo $l; done
   3566 expected-stdout:
   3567 	4#3
   3568 	--
   3569 	-4
   3570 	--
   3571 	2
   3572 	--
   3573 	1
   3574 	5
   3575 	4
   3576 ---
   3577 name: integer-base-6
   3578 description:
   3579 	Even more base stuff
   3580 	(ksh93 fails this test - prints 0)
   3581 stdin:
   3582 	typeset -i7 i
   3583 	i=
   3584 	echo $i
   3585 expected-stdout:
   3586 	7#0
   3587 ---
   3588 name: integer-base-7
   3589 description:
   3590 	Check that non-integer parameters don't get bases assigned
   3591 stdin:
   3592 	echo $(( zz = 8#100 ))
   3593 	echo $zz
   3594 expected-stdout:
   3595 	64
   3596 	64
   3597 ---
   3598 name: lineno-stdin
   3599 description:
   3600 	See if $LINENO is updated and can be modified.
   3601 stdin:
   3602 	echo A $LINENO
   3603 	echo B $LINENO
   3604 	LINENO=20
   3605 	echo C $LINENO
   3606 expected-stdout:
   3607 	A 1
   3608 	B 2
   3609 	C 20
   3610 ---
   3611 name: lineno-inc
   3612 description:
   3613 	See if $LINENO is set for .'d files.
   3614 file-setup: file 644 "dotfile"
   3615 	echo dot A $LINENO
   3616 	echo dot B $LINENO
   3617 	LINENO=20
   3618 	echo dot C $LINENO
   3619 stdin:
   3620 	echo A $LINENO
   3621 	echo B $LINENO
   3622 	. ./dotfile
   3623 expected-stdout:
   3624 	A 1
   3625 	B 2
   3626 	dot A 1
   3627 	dot B 2
   3628 	dot C 20
   3629 ---
   3630 name: lineno-func
   3631 description:
   3632 	See if $LINENO is set for commands in a function.
   3633 stdin:
   3634 	echo A $LINENO
   3635 	echo B $LINENO
   3636 	bar() {
   3637 	    echo func A $LINENO
   3638 	    echo func B $LINENO
   3639 	}
   3640 	bar
   3641 	echo C $LINENO
   3642 expected-stdout:
   3643 	A 1
   3644 	B 2
   3645 	func A 4
   3646 	func B 5
   3647 	C 8
   3648 ---
   3649 name: lineno-unset
   3650 description:
   3651 	See if unsetting LINENO makes it non-magic.
   3652 file-setup: file 644 "dotfile"
   3653 	echo dot A $LINENO
   3654 	echo dot B $LINENO
   3655 stdin:
   3656 	unset LINENO
   3657 	echo A $LINENO
   3658 	echo B $LINENO
   3659 	bar() {
   3660 	    echo func A $LINENO
   3661 	    echo func B $LINENO
   3662 	}
   3663 	bar
   3664 	. ./dotfile
   3665 	echo C $LINENO
   3666 expected-stdout:
   3667 	A
   3668 	B
   3669 	func A
   3670 	func B
   3671 	dot A
   3672 	dot B
   3673 	C
   3674 ---
   3675 name: lineno-unset-use
   3676 description:
   3677 	See if unsetting LINENO makes it non-magic even
   3678 	when it is re-used.
   3679 file-setup: file 644 "dotfile"
   3680 	echo dot A $LINENO
   3681 	echo dot B $LINENO
   3682 stdin:
   3683 	unset LINENO
   3684 	LINENO=3
   3685 	echo A $LINENO
   3686 	echo B $LINENO
   3687 	bar() {
   3688 	    echo func A $LINENO
   3689 	    echo func B $LINENO
   3690 	}
   3691 	bar
   3692 	. ./dotfile
   3693 	echo C $LINENO
   3694 expected-stdout:
   3695 	A 3
   3696 	B 3
   3697 	func A 3
   3698 	func B 3
   3699 	dot A 3
   3700 	dot B 3
   3701 	C 3
   3702 ---
   3703 name: lineno-trap
   3704 description:
   3705 	Check if LINENO is tracked in traps
   3706 stdin:
   3707 	fail() {
   3708 		echo "line <$1>"
   3709 		exit 1
   3710 	}
   3711 	trap 'fail $LINENO' INT ERR
   3712 	false
   3713 expected-stdout:
   3714 	line <6>
   3715 expected-exit: 1
   3716 ---
   3717 name: unknown-trap
   3718 description:
   3719 	Ensure unknown traps are not a syntax error
   3720 stdin:
   3721 	(
   3722 	trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
   3723 	echo =1
   3724 	trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
   3725 	echo = $?
   3726 	) 2>&1 | sed "s^${__progname}: <stdin>\[[0-9]*]PROG"
   3727 expected-stdout:
   3728 	PROG: trap: bad signal 'UNKNOWNSIGNAL'
   3729 	foo
   3730 	=1
   3731 	PROG: trap: bad signal 'UNKNOWNSIGNAL'
   3732 	PROG: trap: bad signal '999999'
   3733 	PROG: trap: bad signal 'FNORD'
   3734 	= 3
   3735 	trap 2 executed
   3736 ---
   3737 name: read-IFS-1
   3738 description:
   3739 	Simple test, default IFS
   3740 stdin:
   3741 	echo "A B " > IN
   3742 	unset x y z
   3743 	read x y z < IN
   3744 	echo 1: "x[$x] y[$y] z[$z]"
   3745 	echo 1a: ${z-z not set}
   3746 	read x < IN
   3747 	echo 2: "x[$x]"
   3748 expected-stdout:
   3749 	1: x[A] y[B] z[]
   3750 	1a:
   3751 	2: x[A B]
   3752 ---
   3753 name: read-ksh-1
   3754 description:
   3755 	If no var specified, REPLY is used
   3756 stdin:
   3757 	echo "abc" > IN
   3758 	read < IN
   3759 	echo "[$REPLY]";
   3760 expected-stdout:
   3761 	[abc]
   3762 ---
   3763 name: read-regress-1
   3764 description:
   3765 	Check a regression of read
   3766 file-setup: file 644 "foo"
   3767 	foo bar
   3768 	baz
   3769 	blah
   3770 stdin:
   3771 	while read a b c; do
   3772 		read d
   3773 		break
   3774 	done <foo
   3775 	echo "<$a|$b|$c><$d>"
   3776 expected-stdout:
   3777 	<foo|bar|><baz>
   3778 ---
   3779 name: read-delim-1
   3780 description:
   3781 	Check read with delimiters
   3782 stdin:
   3783 	emit() {
   3784 		printf 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
   3785 	}
   3786 	emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
   3787 	emit | while read -d "" foo; do print -r -- "<$foo>"; done
   3788 	emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
   3789 expected-stdout:
   3790 	<foo bar	baz
   3791 	blah >
   3792 	<blub	blech
   3793 	myok meck >
   3794 	<foo bar	baz
   3795 	blah>
   3796 	<blub	blech
   3797 	myok meck>
   3798 	<foo bar	baz
   3799 	blah blub	bl>
   3800 	<ch
   3801 	myok m>
   3802 ---
   3803 name: read-ext-1
   3804 description:
   3805 	Check read with number of bytes specified, and -A
   3806 stdin:
   3807 	print 'foo\nbar' >x1
   3808 	print -n x >x2
   3809 	print 'foo\\ bar baz' >x3
   3810 	x1a=u; read x1a <x1
   3811 	x1b=u; read -N-1 x1b <x1
   3812 	x2a=u; read x2a <x2; r2a=$?
   3813 	x2b=u; read -N2 x2c <x2; r2b=$?
   3814 	x2c=u; read -n2 x2c <x2; r2c=$?
   3815 	x3a=u; read -A x3a <x3
   3816 	print -r "x1a=<$x1a>"
   3817 	print -r "x1b=<$x1b>"
   3818 	print -r "x2a=$r2a<$x2a>"
   3819 	print -r "x2b=$r2b<$x2b>"
   3820 	print -r "x2c=$r2c<$x2c>"
   3821 	print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
   3822 expected-stdout:
   3823 	x1a=<foo>
   3824 	x1b=<foo
   3825 	bar>
   3826 	x2a=1<x>
   3827 	x2b=1<u>
   3828 	x2c=0<x>
   3829 	x3a=<foo bar|baz|>
   3830 ---
   3831 name: regression-1
   3832 description:
   3833 	Lex array code had problems with this.
   3834 stdin:
   3835 	echo foo[
   3836 	n=bar
   3837 	echo "hi[ $n ]=1"
   3838 expected-stdout:
   3839 	foo[
   3840 	hi[ bar ]=1
   3841 ---
   3842 name: regression-2
   3843 description:
   3844 	When PATH is set before running a command, the new path is
   3845 	not used in doing the path search
   3846 		$ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
   3847 		$ PATH=/tmp q
   3848 		q: not found
   3849 		$
   3850 	in comexec() the two lines
   3851 		while (*vp != NULL)
   3852 			(void) typeset(*vp++, xxx, 0);
   3853 	need to be moved out of the switch to before findcom() is
   3854 	called - I don't know what this will break.
   3855 stdin:
   3856 	: ${PWD:-`pwd 2> /dev/null`}
   3857 	: ${PWD:?"PWD not set - can't do test"}
   3858 	mkdir Y
   3859 	cat > Y/xxxscript << EOF
   3860 	#!/bin/sh
   3861 	# Need to restore path so echo can be found (some shells don't have
   3862 	# it as a built-in)
   3863 	PATH=\$OLDPATH
   3864 	echo hi
   3865 	exit 0
   3866 	EOF
   3867 	chmod a+rx Y/xxxscript
   3868 	export OLDPATH="$PATH"
   3869 	PATH=$PWD/Y xxxscript
   3870 	exit $?
   3871 expected-stdout:
   3872 	hi
   3873 ---
   3874 name: regression-6
   3875 description:
   3876 	Parsing of $(..) expressions is non-optimal.  It is
   3877 	impossible to have any parentheses inside the expression.
   3878 	I.e.,
   3879 		$ ksh -c 'echo $(echo \( )'
   3880 		no closing quote
   3881 		$ ksh -c 'echo $(echo "(" )'
   3882 		no closing quote
   3883 		$
   3884 	The solution is to hack the parsing clode in lex.c, the
   3885 	question is how to hack it: should any parentheses be
   3886 	escaped by a backslash, or should recursive parsing be done
   3887 	(so quotes could also be used to hide hem).  The former is
   3888 	easier, the later better...
   3889 stdin:
   3890 	echo $(echo \()
   3891 expected-stdout:
   3892 	(
   3893 ---
   3894 name: regression-9
   3895 description:
   3896 	Continue in a for loop does not work right:
   3897 		for i in a b c ; do
   3898 			if [ $i = b ] ; then
   3899 				continue
   3900 			fi
   3901 			echo $i
   3902 		done
   3903 	Prints a forever...
   3904 stdin:
   3905 	first=yes
   3906 	for i in a b c ; do
   3907 		if [ $i = b ] ; then
   3908 			if [ $first = no ] ; then
   3909 				echo 'continue in for loop broken'
   3910 				break	# hope break isn't broken too :-)
   3911 			fi
   3912 			first=no
   3913 			continue
   3914 		fi
   3915 	done
   3916 	echo bye
   3917 expected-stdout:
   3918 	bye
   3919 ---
   3920 name: regression-10
   3921 description:
   3922 	The following:
   3923 		set -- `false`
   3924 		echo $?
   3925 	should print 0 according to POSIX (dash, bash, ksh93, posh)
   3926 	but not 0 according to the getopt(1) manual page, ksh88, and
   3927 	Bourne sh (such as /bin/sh on Solaris).
   3928 	In mksh R39b, we honour POSIX except when -o sh is set.
   3929 stdin:
   3930 	showf() {
   3931 		[[ -o posix ]]; FPOSIX=$((1-$?))
   3932 		[[ -o sh ]]; FSH=$((1-$?))
   3933 		echo -n "FPOSIX=$FPOSIX FSH=$FSH "
   3934 	}
   3935 	set +o posix +o sh
   3936 	showf
   3937 	set -- `false`
   3938 	echo rv=$?
   3939 	set -o sh
   3940 	showf
   3941 	set -- `false`
   3942 	echo rv=$?
   3943 	set -o posix
   3944 	showf
   3945 	set -- `false`
   3946 	echo rv=$?
   3947 expected-stdout:
   3948 	FPOSIX=0 FSH=0 rv=0
   3949 	FPOSIX=0 FSH=1 rv=1
   3950 	FPOSIX=1 FSH=0 rv=0
   3951 ---
   3952 name: regression-11
   3953 description:
   3954 	The following:
   3955 		x=/foo/bar/blah
   3956 		echo ${x##*/}
   3957 	should echo blah but on some machines echos /foo/bar/blah.
   3958 stdin:
   3959 	x=/foo/bar/blah
   3960 	echo ${x##*/}
   3961 expected-stdout:
   3962 	blah
   3963 ---
   3964 name: regression-12
   3965 description:
   3966 	Both of the following echos produce the same output under sh/ksh.att:
   3967 		#!/bin/sh
   3968 		x="foo	bar"
   3969 		echo "`echo \"$x\"`"
   3970 		echo "`echo "$x"`"
   3971 	pdksh produces different output for the former (foo instead of foo\tbar)
   3972 stdin:
   3973 	x="foo	bar"
   3974 	echo "`echo \"$x\"`"
   3975 	echo "`echo "$x"`"
   3976 expected-stdout:
   3977 	foo	bar
   3978 	foo	bar
   3979 ---
   3980 name: regression-13
   3981 description:
   3982 	The following command hangs forever:
   3983 		$ (: ; cat /etc/termcap) | sleep 2
   3984 	This is because the shell forks a shell to run the (..) command
   3985 	and this shell has the pipe open.  When the sleep dies, the cat
   3986 	doesn't get a SIGPIPE 'cause a process (ie, the second shell)
   3987 	still has the pipe open.
   3988 	
   3989 	NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
   3990 	      commands from /etc/termcap..)
   3991 time-limit: 10
   3992 stdin:
   3993 	echo A line of text that will be duplicated quite a number of times.> t1
   3994 	cat t1 t1 t1 t1  t1 t1 t1 t1  t1 t1 t1 t1  t1 t1 t1 t1  > t2
   3995 	cat t2 t2 t2 t2  t2 t2 t2 t2  t2 t2 t2 t2  t2 t2 t2 t2  > t1
   3996 	cat t1 t1 t1 t1 > t2
   3997 	(: ; cat t2 2>&-) | sleep 1
   3998 ---
   3999 name: regression-14
   4000 description:
   4001 	The command
   4002 		$ (foobar) 2> /dev/null
   4003 	generates no output under /bin/sh, but pdksh produces the error
   4004 		foobar: not found
   4005 	Also, the command
   4006 		$ foobar 2> /dev/null
   4007 	generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
   4008 	no error (redirected to /dev/null).
   4009 stdin:
   4010 	(you/should/not/see/this/error/1) 2> /dev/null
   4011 	you/should/not/see/this/error/2 2> /dev/null
   4012 	true
   4013 ---
   4014 name: regression-15
   4015 description:
   4016 	The command
   4017 		$ whence foobar
   4018 	generates a blank line under pdksh and sets the exit status to 0.
   4019 	AT&T ksh88 generates no output and sets the exit status to 1.  Also,
   4020 	the command
   4021 		$ whence foobar cat
   4022 	generates no output under AT&T ksh88 (pdksh generates a blank line
   4023 	and /bin/cat).
   4024 stdin:
   4025 	whence does/not/exist > /dev/null
   4026 	echo 1: $?
   4027 	echo 2: $(whence does/not/exist | wc -l)
   4028 	echo 3: $(whence does/not/exist cat | wc -l)
   4029 expected-stdout:
   4030 	1: 1
   4031 	2: 0
   4032 	3: 0
   4033 ---
   4034 name: regression-16
   4035 description:
   4036 	${var%%expr} seems to be broken in many places.  On the mips
   4037 	the commands
   4038 		$ read line < /etc/passwd
   4039 		$ echo $line
   4040 		root:0:1:...
   4041 		$ echo ${line%%:*}
   4042 		root
   4043 		$ echo $line
   4044 		root
   4045 		$
   4046 	change the value of line.  On sun4s & pas, the echo ${line%%:*} doesn't
   4047 	work.  Haven't checked elsewhere...
   4048 script:
   4049 	read x
   4050 	y=$x
   4051 	echo ${x%%:*}
   4052 	echo $x
   4053 stdin:
   4054 	root:asdjhasdasjhs:0:1:Root:/:/bin/sh
   4055 expected-stdout:
   4056 	root
   4057 	root:asdjhasdasjhs:0:1:Root:/:/bin/sh
   4058 ---
   4059 name: regression-17
   4060 description:
   4061 	The command
   4062 		. /foo/bar
   4063 	should set the exit status to non-zero (sh and AT&T ksh88 do).
   4064 	XXX doting a non existent file is a fatal error for a script
   4065 stdin:
   4066 	. does/not/exist
   4067 expected-exit: e != 0
   4068 expected-stderr-pattern: /.?/
   4069 ---
   4070 name: regression-19
   4071 description:
   4072 	Both of the following echos should produce the same thing, but don't:
   4073 		$ x=foo/bar
   4074 		$ echo ${x%/*}
   4075 		foo
   4076 		$ echo "${x%/*}"
   4077 		foo/bar
   4078 stdin:
   4079 	x=foo/bar
   4080 	echo "${x%/*}"
   4081 expected-stdout:
   4082 	foo
   4083 ---
   4084 name: regression-21
   4085 description:
   4086 	backslash does not work as expected in case labels:
   4087 	$ x='-x'
   4088 	$ case $x in
   4089 	-\?) echo hi
   4090 	esac
   4091 	hi
   4092 	$ x='-?'
   4093 	$ case $x in
   4094 	-\\?) echo hi
   4095 	esac
   4096 	hi
   4097 	$
   4098 stdin:
   4099 	case -x in
   4100 	-\?)	echo fail
   4101 	esac
   4102 ---
   4103 name: regression-22
   4104 description:
   4105 	Quoting backquotes inside backquotes doesn't work:
   4106 	$ echo `echo hi \`echo there\` folks`
   4107 	asks for more info.  sh and AT&T ksh88 both echo
   4108 	hi there folks
   4109 stdin:
   4110 	echo `echo hi \`echo there\` folks`
   4111 expected-stdout:
   4112 	hi there folks
   4113 ---
   4114 name: regression-23
   4115 description:
   4116 	)) is not treated `correctly':
   4117 	    $ (echo hi ; (echo there ; echo folks))
   4118 	    missing ((
   4119 	    $
   4120 	instead of (as sh and ksh.att)
   4121 	    $ (echo hi ; (echo there ; echo folks))
   4122 	    hi
   4123 	    there
   4124 	    folks
   4125 	    $
   4126 stdin:
   4127 	( : ; ( : ; echo hi))
   4128 expected-stdout:
   4129 	hi
   4130 ---
   4131 name: regression-25
   4132 description:
   4133 	Check reading stdin in a while loop.  The read should only read
   4134 	a single line, not a whole stdio buffer; the cat should get
   4135 	the rest.
   4136 stdin:
   4137 	(echo a; echo b) | while read x ; do
   4138 	    echo $x
   4139 	    cat > /dev/null
   4140 	done
   4141 expected-stdout:
   4142 	a
   4143 ---
   4144 name: regression-26
   4145 description:
   4146 	Check reading stdin in a while loop.  The read should read both
   4147 	lines, not just the first.
   4148 script:
   4149 	a=
   4150 	while [ "$a" != xxx ] ; do
   4151 	    last=$x
   4152 	    read x
   4153 	    cat /dev/null | sed 's/x/y/'
   4154 	    a=x$a
   4155 	done
   4156 	echo $last
   4157 stdin:
   4158 	a
   4159 	b
   4160 expected-stdout:
   4161 	b
   4162 ---
   4163 name: regression-27
   4164 description:
   4165 	The command
   4166 		. /does/not/exist
   4167 	should cause a script to exit.
   4168 stdin:
   4169 	. does/not/exist
   4170 	echo hi
   4171 expected-exit: e != 0
   4172 expected-stderr-pattern: /does\/not\/exist/
   4173 ---
   4174 name: regression-28
   4175 description:
   4176 	variable assignements not detected well
   4177 stdin:
   4178 	a.x=1 echo hi
   4179 expected-exit: e != 0
   4180 expected-stderr-pattern: /a\.x=1/
   4181 ---
   4182 name: regression-29
   4183 description:
   4184 	alias expansion different from AT&T ksh88
   4185 stdin:
   4186 	alias a='for ' b='i in'
   4187 	a b hi ; do echo $i ; done
   4188 expected-stdout:
   4189 	hi
   4190 ---
   4191 name: regression-30
   4192 description:
   4193 	strange characters allowed inside ${...}
   4194 stdin:
   4195 	echo ${a{b}}
   4196 expected-exit: e != 0
   4197 expected-stderr-pattern: /.?/
   4198 ---
   4199 name: regression-31
   4200 description:
   4201 	Does read handle partial lines correctly
   4202 script:
   4203 	a= ret=
   4204 	while [ "$a" != xxx ] ; do
   4205 	    read x y z
   4206 	    ret=$?
   4207 	    a=x$a
   4208 	done
   4209 	echo "[$x]"
   4210 	echo $ret
   4211 stdin: !
   4212 	a A aA
   4213 	b B Bb
   4214 	c
   4215 expected-stdout:
   4216 	[c]
   4217 	1
   4218 ---
   4219 name: regression-32
   4220 description:
   4221 	Does read set variables to null at eof?
   4222 script:
   4223 	a=
   4224 	while [ "$a" != xxx ] ; do
   4225 	    read x y z
   4226 	    a=x$a
   4227 	done
   4228 	echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
   4229 	echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
   4230 stdin:
   4231 	a A Aa
   4232 	b B Bb
   4233 expected-stdout:
   4234 	1:
   4235 	2:
   4236 ---
   4237 name: regression-33
   4238 description:
   4239 	Does umask print a leading 0 when umask is 3 digits?
   4240 stdin:
   4241 	# on MiNT, the first umask call seems to fail
   4242 	umask 022
   4243 	# now, the test proper
   4244 	umask 222
   4245 	umask
   4246 expected-stdout:
   4247 	0222
   4248 ---
   4249 name: regression-35
   4250 description:
   4251 	Tempory files used for here-docs in functions get trashed after
   4252 	the function is parsed (before it is executed)
   4253 stdin:
   4254 	f1() {
   4255 		cat <<- EOF
   4256 			F1
   4257 		EOF
   4258 		f2() {
   4259 			cat <<- EOF
   4260 				F2
   4261 			EOF
   4262 		}
   4263 	}
   4264 	f1
   4265 	f2
   4266 	unset -f f1
   4267 	f2
   4268 expected-stdout:
   4269 	F1
   4270 	F2
   4271 	F2
   4272 ---
   4273 name: regression-36
   4274 description:
   4275 	Command substitution breaks reading in while loop
   4276 	(test from <sjg (a] void.zen.oz.au>)
   4277 stdin:
   4278 	(echo abcdef; echo; echo 123) |
   4279 	    while read line
   4280 	    do
   4281 	      # the following line breaks it
   4282 	      c=`echo $line | wc -c`
   4283 	      echo $c
   4284 	    done
   4285 expected-stdout:
   4286 	7
   4287 	1
   4288 	4
   4289 ---
   4290 name: regression-37
   4291 description:
   4292 	Machines with broken times() (reported by <sjg (a] void.zen.oz.au>)
   4293 	time does not report correct real time
   4294 stdin:
   4295 	time sleep 1
   4296 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
   4297 ---
   4298 name: regression-38
   4299 description:
   4300 	set -e doesn't ignore exit codes for if/while/until/&&/||/!.
   4301 arguments: !-e!
   4302 stdin:
   4303 	if false; then echo hi ; fi
   4304 	false || true
   4305 	false && true
   4306 	while false; do echo hi; done
   4307 	echo ok
   4308 expected-stdout:
   4309 	ok
   4310 ---
   4311 name: regression-39
   4312 description:
   4313 	set -e: errors in command substitutions aren't ignored
   4314 	Not clear if they should be or not... bash passes here
   4315 	this may actually be required for make, so changed the
   4316 	test to make this an mksh feature, not a bug
   4317 arguments: !-e!
   4318 stdin:
   4319 	echo `false; echo hi`
   4320 #expected-fail: yes
   4321 #expected-stdout:
   4322 #	hi
   4323 expected-stdout:
   4324 	
   4325 ---
   4326 name: regression-40
   4327 description:
   4328 	This used to cause a core dump
   4329 env-setup: !RANDOM=12!
   4330 stdin:
   4331 	echo hi
   4332 expected-stdout:
   4333 	hi
   4334 ---
   4335 name: regression-41
   4336 description:
   4337 	foo should be set to bar (should not be empty)
   4338 stdin:
   4339 	foo=`
   4340 	echo bar`
   4341 	echo "($foo)"
   4342 expected-stdout:
   4343 	(bar)
   4344 ---
   4345 name: regression-42
   4346 description:
   4347 	Can't use command line assignments to assign readonly parameters.
   4348 stdin:
   4349 	foo=bar
   4350 	readonly foo
   4351 	foo=stuff env | grep '^foo'
   4352 expected-exit: e != 0
   4353 expected-stderr-pattern:
   4354 	/.*read *only.*/
   4355 ---
   4356 name: regression-43
   4357 description:
   4358 	Can subshells be prefixed by redirections (historical shells allow
   4359 	this)
   4360 stdin:
   4361 	< /dev/null (sed 's/^/X/')
   4362 ---
   4363 name: regression-45
   4364 description:
   4365 	Parameter assignments with [] recognised correctly
   4366 stdin:
   4367 	FOO=*[12]
   4368 	BAR=abc[
   4369 	MORE=[abc]
   4370 	JUNK=a[bc
   4371 	echo "<$FOO>"
   4372 	echo "<$BAR>"
   4373 	echo "<$MORE>"
   4374 	echo "<$JUNK>"
   4375 expected-stdout:
   4376 	<*[12]>
   4377 	<abc[>
   4378 	<[abc]>
   4379 	<a[bc>
   4380 ---
   4381 name: regression-46
   4382 description:
   4383 	Check that alias expansion works in command substitutions and
   4384 	at the end of file.
   4385 stdin:
   4386 	alias x='echo hi'
   4387 	FOO="`x` "
   4388 	echo "[$FOO]"
   4389 	x
   4390 expected-stdout:
   4391 	[hi ]
   4392 	hi
   4393 ---
   4394 name: regression-47
   4395 description:
   4396 	Check that aliases are fully read.
   4397 stdin:
   4398 	alias x='echo hi;
   4399 	echo there'
   4400 	x
   4401 	echo done
   4402 expected-stdout:
   4403 	hi
   4404 	there
   4405 	done
   4406 ---
   4407 name: regression-48
   4408 description:
   4409 	Check that (here doc) temp files are not left behind after an exec.
   4410 stdin:
   4411 	mkdir foo || exit 1
   4412 	TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
   4413 		x() {
   4414 			sed 's/^/X /' << E_O_F
   4415 			hi
   4416 			there
   4417 			folks
   4418 			E_O_F
   4419 			echo "done ($?)"
   4420 		}
   4421 		echo=echo; [ -x /bin/echo ] && echo=/bin/echo
   4422 		exec $echo subtest-1 hi
   4423 	EOF
   4424 	echo subtest-1 foo/*
   4425 	TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
   4426 		echo=echo; [ -x /bin/echo ] && echo=/bin/echo
   4427 		sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
   4428 		a
   4429 		few
   4430 		lines
   4431 		E_O_F
   4432 	EOF
   4433 	echo subtest-2 foo/*
   4434 expected-stdout:
   4435 	subtest-1 hi
   4436 	subtest-1 foo/*
   4437 	X a
   4438 	X few
   4439 	X lines
   4440 	subtest-2 hi
   4441 	subtest-2 foo/*
   4442 ---
   4443 name: regression-49
   4444 description:
   4445 	Check that unset params with attributes are reported by set, those
   4446 	sans attributes are not.
   4447 stdin:
   4448 	unset FOO BAR
   4449 	echo X$FOO
   4450 	export BAR
   4451 	typeset -i BLAH
   4452 	set | grep FOO
   4453 	set | grep BAR
   4454 	set | grep BLAH
   4455 expected-stdout:
   4456 	X
   4457 	BAR
   4458 	BLAH
   4459 ---
   4460 name: regression-50
   4461 description:
   4462 	Check that aliases do not use continuation prompt after trailing
   4463 	semi-colon.
   4464 file-setup: file 644 "env"
   4465 	PS1=Y
   4466 	PS2=X
   4467 env-setup: !ENV=./env!
   4468 need-ctty: yes
   4469 arguments: !-i!
   4470 stdin:
   4471 	alias foo='echo hi ; '
   4472 	foo
   4473 	foo echo there
   4474 expected-stdout:
   4475 	hi
   4476 	hi
   4477 	there
   4478 expected-stderr: !
   4479 	YYYY
   4480 ---
   4481 name: regression-51
   4482 description:
   4483 	Check that set allows both +o and -o options on same command line.
   4484 stdin:
   4485 	set a b c
   4486 	set -o noglob +o allexport
   4487 	echo A: $*, *
   4488 expected-stdout:
   4489 	A: a b c, *
   4490 ---
   4491 name: regression-52
   4492 description:
   4493 	Check that globbing works in pipelined commands
   4494 file-setup: file 644 "env"
   4495 	PS1=P
   4496 file-setup: file 644 "abc"
   4497 	stuff
   4498 env-setup: !ENV=./env!
   4499 need-ctty: yes
   4500 arguments: !-i!
   4501 stdin:
   4502 	sed 's/^/X /' < ab*
   4503 	echo mark 1
   4504 	sed 's/^/X /' < ab* | sed 's/^/Y /'
   4505 	echo mark 2
   4506 expected-stdout:
   4507 	X stuff
   4508 	mark 1
   4509 	Y X stuff
   4510 	mark 2
   4511 expected-stderr: !
   4512 	PPPPP
   4513 ---
   4514 name: regression-53
   4515 description:
   4516 	Check that getopts works in functions
   4517 stdin:
   4518 	bfunc() {
   4519 	    echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
   4520 	    while getopts B oc; do
   4521 		case $oc in
   4522 		  (B)
   4523 		    echo bfunc: B option
   4524 		    ;;
   4525 		  (*)
   4526 		    echo bfunc: odd option "($oc)"
   4527 		    ;;
   4528 		esac
   4529 	    done
   4530 	    echo bfunc: leave
   4531 	}
   4532 	
   4533 	function kfunc {
   4534 	    echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
   4535 	    while getopts K oc; do
   4536 		case $oc in
   4537 		  (K)
   4538 		    echo kfunc: K option
   4539 		    ;;
   4540 		  (*)
   4541 		    echo bfunc: odd option "($oc)"
   4542 		    ;;
   4543 		esac
   4544 	    done
   4545 	    echo kfunc: leave
   4546 	}
   4547 	
   4548 	set -- -f -b -k -l
   4549 	echo "line 1: OPTIND=$OPTIND"
   4550 	getopts kbfl optc
   4551 	echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
   4552 	bfunc -BBB blah
   4553 	echo "line 3: OPTIND=$OPTIND"
   4554 	getopts kbfl optc
   4555 	echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
   4556 	kfunc -KKK blah
   4557 	echo "line 5: OPTIND=$OPTIND"
   4558 	getopts kbfl optc
   4559 	echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
   4560 	echo
   4561 	
   4562 	OPTIND=1
   4563 	set -- -fbkl
   4564 	echo "line 10: OPTIND=$OPTIND"
   4565 	getopts kbfl optc
   4566 	echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
   4567 	bfunc -BBB blah
   4568 	echo "line 30: OPTIND=$OPTIND"
   4569 	getopts kbfl optc
   4570 	echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
   4571 	kfunc -KKK blah
   4572 	echo "line 50: OPTIND=$OPTIND"
   4573 	getopts kbfl optc
   4574 	echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
   4575 expected-stdout:
   4576 	line 1: OPTIND=1
   4577 	line 2: ret=0, optc=f, OPTIND=2
   4578 	bfunc: enter (args: -BBB blah; OPTIND=2)
   4579 	bfunc: B option
   4580 	bfunc: B option
   4581 	bfunc: leave
   4582 	line 3: OPTIND=2
   4583 	line 4: ret=0, optc=b, OPTIND=3
   4584 	kfunc: enter (args: -KKK blah; OPTIND=1)
   4585 	kfunc: K option
   4586 	kfunc: K option
   4587 	kfunc: K option
   4588 	kfunc: leave
   4589 	line 5: OPTIND=3
   4590 	line 6: ret=0, optc=k, OPTIND=4
   4591 	
   4592 	line 10: OPTIND=1
   4593 	line 20: ret=0, optc=f, OPTIND=2
   4594 	bfunc: enter (args: -BBB blah; OPTIND=2)
   4595 	bfunc: B option
   4596 	bfunc: B option
   4597 	bfunc: leave
   4598 	line 30: OPTIND=2
   4599 	line 40: ret=1, optc=?, OPTIND=2
   4600 	kfunc: enter (args: -KKK blah; OPTIND=1)
   4601 	kfunc: K option
   4602 	kfunc: K option
   4603 	kfunc: K option
   4604 	kfunc: leave
   4605 	line 50: OPTIND=2
   4606 	line 60: ret=1, optc=?, OPTIND=2
   4607 ---
   4608 name: regression-54
   4609 description:
   4610 	Check that ; is not required before the then in if (( ... )) then ...
   4611 stdin:
   4612 	if (( 1 )) then
   4613 	    echo ok dparen
   4614 	fi
   4615 	if [[ -n 1 ]] then
   4616 	    echo ok dbrackets
   4617 	fi
   4618 expected-stdout:
   4619 	ok dparen
   4620 	ok dbrackets
   4621 ---
   4622 name: regression-55
   4623 description:
   4624 	Check ${foo:%bar} is allowed (ksh88 allows it...)
   4625 stdin:
   4626 	x=fooXbarXblah
   4627 	echo 1 ${x%X*}
   4628 	echo 2 ${x:%X*}
   4629 	echo 3 ${x%%X*}
   4630 	echo 4 ${x:%%X*}
   4631 	echo 5 ${x#*X}
   4632 	echo 6 ${x:#*X}
   4633 	echo 7 ${x##*X}
   4634 	echo 8 ${x:##*X}
   4635 expected-stdout:
   4636 	1 fooXbar
   4637 	2 fooXbar
   4638 	3 foo
   4639 	4 foo
   4640 	5 barXblah
   4641 	6 barXblah
   4642 	7 blah
   4643 	8 blah
   4644 ---
   4645 name: regression-57
   4646 description:
   4647 	Check if typeset output is correct for
   4648 	uninitialised array elements.
   4649 stdin:
   4650 	typeset -i xxx[4]
   4651 	echo A
   4652 	typeset -i | grep xxx | sed 's/^/    /'
   4653 	echo B
   4654 	typeset | grep xxx | sed 's/^/    /'
   4655 	
   4656 	xxx[1]=2+5
   4657 	echo M
   4658 	typeset -i | grep xxx | sed 's/^/    /'
   4659 	echo N
   4660 	typeset | grep xxx | sed 's/^/    /'
   4661 expected-stdout:
   4662 	A
   4663 	    xxx
   4664 	B
   4665 	    typeset -i xxx
   4666 	M
   4667 	    xxx[1]=7
   4668 	N
   4669 	    typeset -i xxx
   4670 ---
   4671 name: regression-58
   4672 description:
   4673 	Check if trap exit is ok (exit not mistaken for signal name)
   4674 stdin:
   4675 	trap 'echo hi' exit
   4676 	trap exit 1
   4677 expected-stdout:
   4678 	hi
   4679 ---
   4680 name: regression-59
   4681 description:
   4682 	Check if ${#array[*]} is calculated correctly.
   4683 stdin:
   4684 	a[12]=hi
   4685 	a[8]=there
   4686 	echo ${#a[*]}
   4687 expected-stdout:
   4688 	2
   4689 ---
   4690 name: regression-60
   4691 description:
   4692 	Check if default exit status is previous command
   4693 stdin:
   4694 	(true; exit)
   4695 	echo A $?
   4696 	(false; exit)
   4697 	echo B $?
   4698 	( (exit 103) ; exit)
   4699 	echo C $?
   4700 expected-stdout:
   4701 	A 0
   4702 	B 1
   4703 	C 103
   4704 ---
   4705 name: regression-61
   4706 description:
   4707 	Check if EXIT trap is executed for sub shells.
   4708 stdin:
   4709 	trap 'echo parent exit' EXIT
   4710 	echo start
   4711 	(echo A; echo A last)
   4712 	echo B
   4713 	(echo C; trap 'echo sub exit' EXIT; echo C last)
   4714 	echo parent last
   4715 expected-stdout:
   4716 	start
   4717 	A
   4718 	A last
   4719 	B
   4720 	C
   4721 	C last
   4722 	sub exit
   4723 	parent last
   4724 	parent exit
   4725 ---
   4726 name: regression-62
   4727 description:
   4728 	Check if test -nt/-ot succeeds if second(first) file is missing.
   4729 stdin:
   4730 	touch a
   4731 	test a -nt b && echo nt OK || echo nt BAD
   4732 	test b -ot a && echo ot OK || echo ot BAD
   4733 expected-stdout:
   4734 	nt OK
   4735 	ot OK
   4736 ---
   4737 name: regression-63
   4738 description:
   4739 	Check if typeset, export, and readonly work
   4740 stdin:
   4741 	{
   4742 		echo FNORD-0
   4743 		FNORD_A=1
   4744 		FNORD_B=2
   4745 		FNORD_C=3
   4746 		FNORD_D=4
   4747 		FNORD_E=5
   4748 		FNORD_F=6
   4749 		FNORD_G=7
   4750 		FNORD_H=8
   4751 		integer FNORD_E FNORD_F FNORD_G FNORD_H
   4752 		export FNORD_C FNORD_D FNORD_G FNORD_H
   4753 		readonly FNORD_B FNORD_D FNORD_F FNORD_H
   4754 		echo FNORD-1
   4755 		export
   4756 		echo FNORD-2
   4757 		export -p
   4758 		echo FNORD-3
   4759 		readonly
   4760 		echo FNORD-4
   4761 		readonly -p
   4762 		echo FNORD-5
   4763 		typeset
   4764 		echo FNORD-6
   4765 		typeset -p
   4766 		echo FNORD-7
   4767 		typeset -
   4768 		echo FNORD-8
   4769 	} | fgrep FNORD
   4770 expected-stdout:
   4771 	FNORD-0
   4772 	FNORD-1
   4773 	FNORD_C
   4774 	FNORD_D
   4775 	FNORD_G
   4776 	FNORD_H
   4777 	FNORD-2
   4778 	export FNORD_C=3
   4779 	export FNORD_D=4
   4780 	export FNORD_G=7
   4781 	export FNORD_H=8
   4782 	FNORD-3
   4783 	FNORD_B
   4784 	FNORD_D
   4785 	FNORD_F
   4786 	FNORD_H
   4787 	FNORD-4
   4788 	readonly FNORD_B=2
   4789 	readonly FNORD_D=4
   4790 	readonly FNORD_F=6
   4791 	readonly FNORD_H=8
   4792 	FNORD-5
   4793 	typeset FNORD_A
   4794 	typeset -r FNORD_B
   4795 	typeset -x FNORD_C
   4796 	typeset -x -r FNORD_D
   4797 	typeset -i FNORD_E
   4798 	typeset -i -r FNORD_F
   4799 	typeset -i -x FNORD_G
   4800 	typeset -i -x -r FNORD_H
   4801 	FNORD-6
   4802 	typeset FNORD_A=1
   4803 	typeset -r FNORD_B=2
   4804 	typeset -x FNORD_C=3
   4805 	typeset -x -r FNORD_D=4
   4806 	typeset -i FNORD_E=5
   4807 	typeset -i -r FNORD_F=6
   4808 	typeset -i -x FNORD_G=7
   4809 	typeset -i -x -r FNORD_H=8
   4810 	FNORD-7
   4811 	FNORD_A=1
   4812 	FNORD_B=2
   4813 	FNORD_C=3
   4814 	FNORD_D=4
   4815 	FNORD_E=5
   4816 	FNORD_F=6
   4817 	FNORD_G=7
   4818 	FNORD_H=8
   4819 	FNORD-8
   4820 ---
   4821 name: regression-64
   4822 description:
   4823 	Check that we can redefine functions calling time builtin
   4824 stdin:
   4825 	t() {
   4826 		time >/dev/null
   4827 	}
   4828 	t 2>/dev/null
   4829 	t() {
   4830 		time
   4831 	}
   4832 ---
   4833 name: regression-65
   4834 description:
   4835 	check for a regression with sleep builtin and signal mask
   4836 category: !nojsig
   4837 time-limit: 3
   4838 stdin:
   4839 	sleep 1
   4840 	echo blub |&
   4841 	while read -p line; do :; done
   4842 	echo ok
   4843 expected-stdout:
   4844 	ok
   4845 ---
   4846 name: readonly-0
   4847 description:
   4848 	Ensure readonly is honoured for assignments and unset
   4849 stdin:
   4850 	"$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
   4851 	echo =
   4852 	"$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
   4853 	echo =
   4854 	"$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
   4855 expected-stdout:
   4856 	0 x .
   4857 	=
   4858 	aborted, 2
   4859 	=
   4860 	1 x .
   4861 expected-stderr-pattern:
   4862 	/read *only/
   4863 ---
   4864 name: readonly-1
   4865 description:
   4866 	http://austingroupbugs.net/view.php?id=367 for export
   4867 stdin:
   4868 	"$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
   4869 expected-stdout:
   4870 	aborted, 2
   4871 expected-stderr-pattern:
   4872 	/read *only/
   4873 ---
   4874 name: readonly-2a
   4875 description:
   4876 	Check that getopts works as intended, for readonly-2b to be valid
   4877 stdin:
   4878 	"$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
   4879 expected-stdout:
   4880 	0 a .
   4881 	1 ? .
   4882 ---
   4883 name: readonly-2b
   4884 description:
   4885 	http://austingroupbugs.net/view.php?id=367 for getopts
   4886 stdin:
   4887 	"$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
   4888 expected-stdout:
   4889 	2 .
   4890 expected-stderr-pattern:
   4891 	/read *only/
   4892 ---
   4893 name: readonly-3
   4894 description:
   4895 	http://austingroupbugs.net/view.php?id=367 for read
   4896 stdin:
   4897 	echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
   4898 	echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
   4899 expected-stdout:
   4900 	0 x .
   4901 	2 .
   4902 expected-stderr-pattern:
   4903 	/read *only/
   4904 ---
   4905 name: syntax-1
   4906 description:
   4907 	Check that lone ampersand is a syntax error
   4908 stdin:
   4909 	 &
   4910 expected-exit: e != 0
   4911 expected-stderr-pattern:
   4912 	/syntax error/
   4913 ---
   4914 name: xxx-quoted-newline-1
   4915 description:
   4916 	Check that \<newline> works inside of ${}
   4917 stdin:
   4918 	abc=2
   4919 	echo ${ab\
   4920 	c}
   4921 expected-stdout:
   4922 	2
   4923 ---
   4924 name: xxx-quoted-newline-2
   4925 description:
   4926 	Check that \<newline> works at the start of a here document
   4927 stdin:
   4928 	cat << EO\
   4929 	F
   4930 	hi
   4931 	EOF
   4932 expected-stdout:
   4933 	hi
   4934 ---
   4935 name: xxx-quoted-newline-3
   4936 description:
   4937 	Check that \<newline> works at the end of a here document
   4938 stdin:
   4939 	cat << EOF
   4940 	hi
   4941 	EO\
   4942 	F
   4943 expected-stdout:
   4944 	hi
   4945 ---
   4946 name: xxx-multi-assignment-cmd
   4947 description:
   4948 	Check that assignments in a command affect subsequent assignments
   4949 	in the same command
   4950 stdin:
   4951 	FOO=abc
   4952 	FOO=123 BAR=$FOO
   4953 	echo $BAR
   4954 expected-stdout:
   4955 	123
   4956 ---
   4957 name: xxx-multi-assignment-posix-cmd
   4958 description:
   4959 	Check that the behaviour for multiple assignments with a
   4960 	command name matches POSIX. See:
   4961 	http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
   4962 stdin:
   4963 	X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
   4964 	unset X Y Z
   4965 	X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
   4966 	unset X Y Z
   4967 	X=a Y=${X=b} Z=$X; echo 4 $Z .
   4968 expected-stdout:
   4969 	1 b a .
   4970 	2 a b .
   4971 	3 b .
   4972 	4 a .
   4973 ---
   4974 name: xxx-multi-assignment-posix-nocmd
   4975 description:
   4976 	Check that the behaviour for multiple assignments with no
   4977 	command name matches POSIX (Debian #334182). See:
   4978 	http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
   4979 stdin:
   4980 	X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
   4981 expected-stdout:
   4982 	1 b b .
   4983 ---
   4984 name: xxx-multi-assignment-posix-subassign
   4985 description:
   4986 	Check that the behaviour for multiple assignments matches POSIX:
   4987 	- The assignment words shall be expanded in the current execution
   4988 	  environment.
   4989 	- The assignments happen in the temporary execution environment.
   4990 stdin:
   4991 	unset X Y Z
   4992 	Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
   4993 	echo /$X/
   4994 	# Now for the special case:
   4995 	unset X Y Z
   4996 	X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
   4997 	echo /$X/
   4998 expected-stdout:
   4999 	++ +b+ +a+
   5000 	/b/
   5001 	++ +b+
   5002 	/b/
   5003 ---
   5004 name: xxx-exec-environment-1
   5005 description:
   5006 	Check to see if exec sets it's environment correctly
   5007 stdin:
   5008 	FOO=bar exec env
   5009 expected-stdout-pattern:
   5010 	/(^|.*\n)FOO=bar\n/
   5011 ---
   5012 name: xxx-exec-environment-2
   5013 description:
   5014 	Check to make sure exec doesn't change environment if a program
   5015 	isn't exec-ed
   5016 stdin:
   5017 	sortprog=$(whence -p sort) || sortprog=cat
   5018 	env | $sortprog | grep -v '^RANDOM=' >bar1
   5019 	FOO=bar exec; env | $sortprog | grep -v '^RANDOM=' >bar2
   5020 	cmp -s bar1 bar2
   5021 ---
   5022 name: exec-function-environment-1
   5023 description:
   5024 	Check assignments in function calls and whether they affect
   5025 	the current execution environment (ksh93, SUSv4)
   5026 stdin:
   5027 	f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
   5028 	echo x$a-$b- z$c-
   5029 expected-stdout:
   5030 	y1-
   5031 	x2-3- z1-
   5032 ---
   5033 name: xxx-what-do-you-call-this-1
   5034 stdin:
   5035 	echo "${foo:-"a"}*"
   5036 expected-stdout:
   5037 	a*
   5038 ---
   5039 name: xxx-prefix-strip-1
   5040 stdin:
   5041 	foo='a cdef'
   5042 	echo ${foo#a c}
   5043 expected-stdout:
   5044 	def
   5045 ---
   5046 name: xxx-prefix-strip-2
   5047 stdin:
   5048 	set a c
   5049 	x='a cdef'
   5050 	echo ${x#$*}
   5051 expected-stdout:
   5052 	def
   5053 ---
   5054 name: xxx-variable-syntax-1
   5055 stdin:
   5056 	echo ${:}
   5057 expected-stderr-pattern:
   5058 	/bad substitution/
   5059 expected-exit: 1
   5060 ---
   5061 name: xxx-variable-syntax-2
   5062 stdin:
   5063 	set 0
   5064 	echo ${*:0}
   5065 expected-stderr-pattern:
   5066 	/bad substitution/
   5067 expected-exit: 1
   5068 ---
   5069 name: xxx-variable-syntax-3
   5070 stdin:
   5071 	set -A foo 0
   5072 	echo ${foo[*]:0}
   5073 expected-stderr-pattern:
   5074 	/bad substitution/
   5075 expected-exit: 1
   5076 ---
   5077 name: xxx-substitution-eval-order
   5078 description:
   5079 	Check order of evaluation of expressions
   5080 stdin:
   5081 	i=1 x= y=
   5082 	set -A A abc def GHI j G k
   5083 	echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
   5084 	echo $x $y
   5085 expected-stdout:
   5086 	HI
   5087 	2 4
   5088 ---
   5089 name: xxx-set-option-1
   5090 description:
   5091 	Check option parsing in set
   5092 stdin:
   5093 	set -vsA foo -- A 1 3 2
   5094 	echo ${foo[*]}
   5095 expected-stderr:
   5096 	echo ${foo[*]}
   5097 expected-stdout:
   5098 	1 2 3 A
   5099 ---
   5100 name: xxx-exec-1
   5101 description:
   5102 	Check that exec exits for built-ins
   5103 need-ctty: yes
   5104 arguments: !-i!
   5105 stdin:
   5106 	exec echo hi
   5107 	echo still herre
   5108 expected-stdout:
   5109 	hi
   5110 expected-stderr-pattern: /.*/
   5111 ---
   5112 name: xxx-while-1
   5113 description:
   5114 	Check the return value of while loops
   5115 	XXX need to do same for for/select/until loops
   5116 stdin:
   5117 	i=x
   5118 	while [ $i != xxx ] ; do
   5119 	    i=x$i
   5120 	    if [ $i = xxx ] ; then
   5121 		false
   5122 		continue
   5123 	    fi
   5124 	done
   5125 	echo loop1=$?
   5126 	
   5127 	i=x
   5128 	while [ $i != xxx ] ; do
   5129 	    i=x$i
   5130 	    if [ $i = xxx ] ; then
   5131 		false
   5132 		break
   5133 	    fi
   5134 	done
   5135 	echo loop2=$?
   5136 	
   5137 	i=x
   5138 	while [ $i != xxx ] ; do
   5139 	    i=x$i
   5140 	    false
   5141 	done
   5142 	echo loop3=$?
   5143 expected-stdout:
   5144 	loop1=0
   5145 	loop2=0
   5146 	loop3=1
   5147 ---
   5148 name: xxx-status-1
   5149 description:
   5150 	Check that blank lines don't clear $?
   5151 need-ctty: yes
   5152 arguments: !-i!
   5153 stdin:
   5154 	(exit 1)
   5155 	echo $?
   5156 	(exit 1)
   5157 	
   5158 	echo $?
   5159 	true
   5160 expected-stdout:
   5161 	1
   5162 	1
   5163 expected-stderr-pattern: /.*/
   5164 ---
   5165 name: xxx-status-2
   5166 description:
   5167 	Check that $? is preserved in subshells, includes, traps.
   5168 stdin:
   5169 	(exit 1)
   5170 	
   5171 	echo blank: $?
   5172 	
   5173 	(exit 2)
   5174 	(echo subshell: $?)
   5175 	
   5176 	echo 'echo include: $?' > foo
   5177 	(exit 3)
   5178 	. ./foo
   5179 	
   5180 	trap 'echo trap: $?' ERR
   5181 	(exit 4)
   5182 	echo exit: $?
   5183 expected-stdout:
   5184 	blank: 1
   5185 	subshell: 2
   5186 	include: 3
   5187 	trap: 4
   5188 	exit: 4
   5189 ---
   5190 name: xxx-clean-chars-1
   5191 description:
   5192 	Check MAGIC character is stuffed correctly
   5193 stdin:
   5194 	echo `echo [`
   5195 expected-stdout:
   5196 	[
   5197 ---
   5198 name: xxx-param-subst-qmark-1
   5199 description:
   5200 	Check suppresion of error message with null string.  According to
   5201 	POSIX, it shouldn't print the error as 'word' isn't ommitted.
   5202 	ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
   5203 	that's why the condition is reversed.
   5204 stdin:
   5205 	unset foo
   5206 	x=
   5207 	echo x${foo?$x}
   5208 expected-exit: 1
   5209 # POSIX
   5210 #expected-fail: yes
   5211 #expected-stderr-pattern: !/not set/
   5212 # common use
   5213 expected-stderr-pattern: /parameter null or not set/
   5214 ---
   5215 name: xxx-param-_-1
   5216 # fails due to weirdness of execv stuff
   5217 category: !os:uwin-nt
   5218 description:
   5219 	Check c flag is set.
   5220 arguments: !-c!echo "[$-]"!
   5221 expected-stdout-pattern: /^\[.*c.*\]$/
   5222 ---
   5223 name: tilde-expand-1
   5224 description:
   5225 	Check tilde expansion after equal signs
   5226 env-setup: !HOME=/sweet!
   5227 stdin:
   5228 	echo ${A=a=}~ b=~ c=d~ ~
   5229 	set +o braceexpand
   5230 	echo ${A=a=}~ b=~ c=d~ ~
   5231 expected-stdout:
   5232 	a=/sweet b=/sweet c=d~ /sweet
   5233 	a=~ b=~ c=d~ /sweet
   5234 ---
   5235 name: exit-err-1
   5236 description:
   5237 	Check some "exit on error" conditions
   5238 stdin:
   5239 	set -ex
   5240 	env false && echo something
   5241 	echo END
   5242 expected-stdout:
   5243 	END
   5244 expected-stderr:
   5245 	+ env false
   5246 	+ echo END
   5247 ---
   5248 name: exit-err-2
   5249 description:
   5250 	Check some "exit on error" edge conditions (POSIXly)
   5251 stdin:
   5252 	set -ex
   5253 	if env true; then
   5254 		env false && echo something
   5255 	fi
   5256 	echo END
   5257 expected-stdout:
   5258 	END
   5259 expected-stderr:
   5260 	+ env true
   5261 	+ env false
   5262 	+ echo END
   5263 ---
   5264 name: exit-err-3
   5265 description:
   5266 	pdksh regression which AT&T ksh does right
   5267 	TFM says: [set] -e | errexit
   5268 		Exit (after executing the ERR trap) ...
   5269 stdin:
   5270 	trap 'echo EXIT' EXIT
   5271 	trap 'echo ERR' ERR
   5272 	set -e
   5273 	cd /XXXXX 2>/dev/null
   5274 	echo DONE
   5275 	exit 0
   5276 expected-stdout:
   5277 	ERR
   5278 	EXIT
   5279 expected-exit: e != 0
   5280 ---
   5281 name: exit-err-4
   5282 description:
   5283 	"set -e" test suite (POSIX)
   5284 stdin:
   5285 	set -e
   5286 	echo pre
   5287 	if true ; then
   5288 		false && echo foo
   5289 	fi
   5290 	echo bar
   5291 expected-stdout:
   5292 	pre
   5293 	bar
   5294 ---
   5295 name: exit-err-5
   5296 description:
   5297 	"set -e" test suite (POSIX)
   5298 stdin:
   5299 	set -e
   5300 	foo() {
   5301 		while [ "$1" ]; do
   5302 			for E in $x; do
   5303 				[ "$1" = "$E" ] && { shift ; continue 2 ; }
   5304 			done
   5305 			x="$x $1"
   5306 			shift
   5307 		done
   5308 		echo $x
   5309 	}
   5310 	echo pre
   5311 	foo a b b c
   5312 	echo post
   5313 expected-stdout:
   5314 	pre
   5315 	a b c
   5316 	post
   5317 ---
   5318 name: exit-err-6
   5319 description:
   5320 	"set -e" test suite (BSD make)
   5321 category: os:mirbsd
   5322 stdin:
   5323 	mkdir zd zd/a zd/b
   5324 	print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
   5325 	print 'all:\n\t@echo zwei\n' >zd/b/Makefile
   5326 	wd=$(pwd)
   5327 	set -e
   5328 	for entry in a b; do (  set -e;  if [[ -d $wd/zd/$entry.i386 ]]; then  _newdir_="$entry.i386";  else  _newdir_="$entry";  fi;  if [[ -z $_THISDIR_ ]]; then  _nextdir_="$_newdir_";  else  _nextdir_="$_THISDIR_/$_newdir_";  fi;  _makefile_spec_=;  [[ ! -f $wd/zd/$_newdir_/Makefile.bsd-wrapper ]]  || _makefile_spec_="-f Makefile.bsd-wrapper";  subskipdir=;  for skipdir in ; do  subentry=${skipdir#$entry};  if [[ $subentry != $skipdir ]]; then  if [[ -z $subentry ]]; then  echo "($_nextdir_ skipped)";  break;  fi;  subskipdir="$subskipdir ${subentry#/}";  fi;  done;  if [[ -z $skipdir || -n $subentry ]]; then  echo "===> $_nextdir_";  cd $wd/zd/$_newdir_;  make SKIPDIR="$subskipdir" $_makefile_spec_  _THISDIR_="$_nextdir_"   all;  fi;  ) done 2>&1 | sed "s!$wd!WD!g"
   5329 expected-stdout:
   5330 	===> a
   5331 	eins
   5332 	*** Error code 42
   5333 	
   5334 	Stop in WD/zd/a (line 2 of Makefile).
   5335 ---
   5336 name: exit-enoent-1
   5337 description:
   5338 	SUSv4 says that the shell should exit with 126/127 in some situations
   5339 stdin:
   5340 	i=0
   5341 	(echo; echo :) >x
   5342 	"$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
   5343 	"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
   5344 	echo exit 42 >x
   5345 	"$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
   5346 	"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
   5347 	rm -f x
   5348 	"$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
   5349 	"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
   5350 expected-stdout:
   5351 	0 0 .
   5352 	1 126 .
   5353 	2 42 .
   5354 	3 126 .
   5355 	4 127 .
   5356 	5 127 .
   5357 ---
   5358 name: exit-eval-1
   5359 description:
   5360 	Check eval vs substitution exit codes (ksh93 alike)
   5361 stdin:
   5362 	eval $(false)
   5363 	echo A $?
   5364 	eval ' $(false)'
   5365 	echo B $?
   5366 	eval " $(false)"
   5367 	echo C $?
   5368 	eval "eval $(false)"
   5369 	echo D $?
   5370 	eval 'eval '"$(false)"
   5371 	echo E $?
   5372 	IFS="$IFS:"
   5373 	eval $(echo :; false)
   5374 	echo F $?
   5375 expected-stdout:
   5376 	A 0
   5377 	B 1
   5378 	C 0
   5379 	D 0
   5380 	E 0
   5381 	F 0
   5382 ---
   5383 name: exit-trap-1
   5384 description:
   5385 	Check that "exit" with no arguments behaves SUSv4 conformant.
   5386 stdin:
   5387 	trap 'echo hi; exit' EXIT
   5388 	exit 9
   5389 expected-stdout:
   5390 	hi
   5391 expected-exit: 9
   5392 ---
   5393 name: test-stlt-1
   5394 description:
   5395 	Check that test also can handle string1 < string2 etc.
   5396 stdin:
   5397 	test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
   5398 	test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
   5399 	test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
   5400 	test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
   5401 expected-stdout:
   5402 	nein
   5403 	ja
   5404 	ja
   5405 	nein
   5406 expected-stderr-pattern: !/unexpected op/
   5407 ---
   5408 name: test-precedence-1
   5409 description:
   5410 	Check a weird precedence case (and POSIX echo)
   5411 stdin:
   5412 	test \( -f = -f \)
   5413 	rv=$?
   5414 	test -n "$POSH_VERSION" || set -o sh
   5415 	echo -e $rv
   5416 expected-stdout:
   5417 	-e 0
   5418 ---
   5419 name: test-option-1
   5420 description:
   5421 	Test the test -o operator
   5422 stdin:
   5423 	runtest() {
   5424 		test -o $1; echo $?
   5425 		[ -o $1 ]; echo $?
   5426 		[[ -o $1 ]]; echo $?
   5427 	}
   5428 	if_test() {
   5429 		test -o $1 -o -o !$1; echo $?
   5430 		[ -o $1 -o -o !$1 ]; echo $?
   5431 		[[ -o $1 || -o !$1 ]]; echo $?
   5432 		test -o ?$1; echo $?
   5433 	}
   5434 	echo 0y $(if_test utf8-mode) =
   5435 	echo 0n $(if_test utf8-hack) =
   5436 	echo 1= $(runtest utf8-hack) =
   5437 	echo 2= $(runtest !utf8-hack) =
   5438 	echo 3= $(runtest ?utf8-hack) =
   5439 	set +U
   5440 	echo 1+ $(runtest utf8-mode) =
   5441 	echo 2+ $(runtest !utf8-mode) =
   5442 	echo 3+ $(runtest ?utf8-mode) =
   5443 	set -U
   5444 	echo 1- $(runtest utf8-mode) =
   5445 	echo 2- $(runtest !utf8-mode) =
   5446 	echo 3- $(runtest ?utf8-mode) =
   5447 	echo = short flags =
   5448 	echo 0y $(if_test -U) =
   5449 	echo 0y $(if_test +U) =
   5450 	echo 0n $(if_test -_) =
   5451 	echo 0n $(if_test -U-) =
   5452 	echo 1= $(runtest -_) =
   5453 	echo 2= $(runtest !-_) =
   5454 	echo 3= $(runtest ?-_) =
   5455 	set +U
   5456 	echo 1+ $(runtest -U) =
   5457 	echo 2+ $(runtest !-U) =
   5458 	echo 3+ $(runtest ?-U) =
   5459 	echo 1+ $(runtest +U) =
   5460 	echo 2+ $(runtest !+U) =
   5461 	echo 3+ $(runtest ?+U) =
   5462 	set -U
   5463 	echo 1- $(runtest -U) =
   5464 	echo 2- $(runtest !-U) =
   5465 	echo 3- $(runtest ?-U) =
   5466 	echo 1- $(runtest +U) =
   5467 	echo 2- $(runtest !+U) =
   5468 	echo 3- $(runtest ?+U) =
   5469 expected-stdout:
   5470 	0y 0 0 0 0 =
   5471 	0n 1 1 1 1 =
   5472 	1= 1 1 1 =
   5473 	2= 1 1 1 =
   5474 	3= 1 1 1 =
   5475 	1+ 1 1 1 =
   5476 	2+ 0 0 0 =
   5477 	3+ 0 0 0 =
   5478 	1- 0 0 0 =
   5479 	2- 1 1 1 =
   5480 	3- 0 0 0 =
   5481 	= short flags =
   5482 	0y 0 0 0 0 =
   5483 	0y 0 0 0 0 =
   5484 	0n 1 1 1 1 =
   5485 	0n 1 1 1 1 =
   5486 	1= 1 1 1 =
   5487 	2= 1 1 1 =
   5488 	3= 1 1 1 =
   5489 	1+ 1 1 1 =
   5490 	2+ 0 0 0 =
   5491 	3+ 0 0 0 =
   5492 	1+ 1 1 1 =
   5493 	2+ 0 0 0 =
   5494 	3+ 0 0 0 =
   5495 	1- 0 0 0 =
   5496 	2- 1 1 1 =
   5497 	3- 0 0 0 =
   5498 	1- 0 0 0 =
   5499 	2- 1 1 1 =
   5500 	3- 0 0 0 =
   5501 ---
   5502 name: mkshrc-1
   5503 description:
   5504 	Check that ~/.mkshrc works correctly.
   5505 	Part 1: verify user environment is not read (internal)
   5506 stdin:
   5507 	echo x $FNORD
   5508 expected-stdout:
   5509 	x
   5510 ---
   5511 name: mkshrc-2a
   5512 description:
   5513 	Check that ~/.mkshrc works correctly.
   5514 	Part 2: verify mkshrc is not read (non-interactive shells)
   5515 file-setup: file 644 ".mkshrc"
   5516 	FNORD=42
   5517 env-setup: !HOME=.!ENV=!
   5518 stdin:
   5519 	echo x $FNORD
   5520 expected-stdout:
   5521 	x
   5522 ---
   5523 name: mkshrc-2b
   5524 description:
   5525 	Check that ~/.mkshrc works correctly.
   5526 	Part 2: verify mkshrc can be read (interactive shells)
   5527 file-setup: file 644 ".mkshrc"
   5528 	FNORD=42
   5529 need-ctty: yes
   5530 arguments: !-i!
   5531 env-setup: !HOME=.!ENV=!PS1=!
   5532 stdin:
   5533 	echo x $FNORD
   5534 expected-stdout:
   5535 	x 42
   5536 expected-stderr-pattern:
   5537 	/(# )*/
   5538 ---
   5539 name: mkshrc-3
   5540 description:
   5541 	Check that ~/.mkshrc works correctly.
   5542 	Part 3: verify mkshrc can be turned off
   5543 file-setup: file 644 ".mkshrc"
   5544 	FNORD=42
   5545 env-setup: !HOME=.!ENV=nonexistant!
   5546 stdin:
   5547 	echo x $FNORD
   5548 expected-stdout:
   5549 	x
   5550 ---
   5551 name: sh-mode-1
   5552 description:
   5553 	Check that sh mode turns braceexpand off
   5554 	and that that works correctly
   5555 stdin:
   5556 	set -o braceexpand
   5557 	set +o sh
   5558 	[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
   5559 	[[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
   5560 	echo {a,b,c}
   5561 	set +o braceexpand
   5562 	echo {a,b,c}
   5563 	set -o braceexpand
   5564 	echo {a,b,c}
   5565 	set -o sh
   5566 	echo {a,b,c}
   5567 	[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
   5568 	[[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
   5569 	set -o braceexpand
   5570 	echo {a,b,c}
   5571 	[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
   5572 	[[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
   5573 expected-stdout:
   5574 	nosh
   5575 	brex
   5576 	a b c
   5577 	{a,b,c}
   5578 	a b c
   5579 	{a,b,c}
   5580 	sh
   5581 	nobrex
   5582 	a b c
   5583 	sh
   5584 	brex
   5585 ---
   5586 name: sh-mode-2a
   5587 description:
   5588 	Check that sh mode is *not* automatically turned on
   5589 category: !binsh
   5590 stdin:
   5591 	ln -s "$__progname" ksh
   5592 	ln -s "$__progname" sh
   5593 	ln -s "$__progname" ./-ksh
   5594 	ln -s "$__progname" ./-sh
   5595 	for shell in {,-}{,k}sh; do
   5596 		print -- $shell $(./$shell +l -c \
   5597 		    '[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh')
   5598 	done
   5599 expected-stdout:
   5600 	sh nosh
   5601 	ksh nosh
   5602 	-sh nosh
   5603 	-ksh nosh
   5604 ---
   5605 name: sh-mode-2b
   5606 description:
   5607 	Check that sh mode *is* automatically turned on
   5608 category: binsh
   5609 stdin:
   5610 	ln -s "$__progname" ksh
   5611 	ln -s "$__progname" sh
   5612 	ln -s "$__progname" ./-ksh
   5613 	ln -s "$__progname" ./-sh
   5614 	for shell in {,-}{,k}sh; do
   5615 		print -- $shell $(./$shell +l -c \
   5616 		    '[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh')
   5617 	done
   5618 expected-stdout:
   5619 	sh sh
   5620 	ksh nosh
   5621 	-sh sh
   5622 	-ksh nosh
   5623 ---
   5624 name: pipeline-1
   5625 description:
   5626 	pdksh bug: last command of a pipeline is executed in a
   5627 	subshell - make sure it still is, scripts depend on it
   5628 file-setup: file 644 "abcx"
   5629 file-setup: file 644 "abcy"
   5630 stdin:
   5631 	echo *
   5632 	echo a | while read d; do
   5633 		echo $d
   5634 		echo $d*
   5635 		echo *
   5636 		set -o noglob
   5637 		echo $d*
   5638 		echo *
   5639 	done
   5640 	echo *
   5641 expected-stdout:
   5642 	abcx abcy
   5643 	a
   5644 	abcx abcy
   5645 	abcx abcy
   5646 	a*
   5647 	*
   5648 	abcx abcy
   5649 ---
   5650 name: pipeline-2
   5651 description:
   5652 	check that co-processes work with TCOMs, TPIPEs and TPARENs
   5653 category: !nojsig
   5654 stdin:
   5655 	"$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
   5656 	"$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
   5657 	"$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
   5658 expected-stdout:
   5659 	100 hi
   5660 	200 hi
   5661 	300 hi
   5662 ---
   5663 name: pipeline-3
   5664 description:
   5665 	Check that PIPESTATUS does what it's supposed to
   5666 stdin:
   5667 	echo 1 $PIPESTATUS .
   5668 	echo 2 ${PIPESTATUS[0]} .
   5669 	echo 3 ${PIPESTATUS[1]} .
   5670 	(echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
   5671 	echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
   5672 	echo 6 ${PIPESTATUS[0]} .
   5673 	set | fgrep PIPESTATUS
   5674 	echo 8 $(set | fgrep PIPESTATUS) .
   5675 expected-stdout:
   5676 	1 0 .
   5677 	2 0 .
   5678 	3 .
   5679 	x
   5680 	5 42 , 12 , 12 , 23 , 42 , .
   5681 	6 0 .
   5682 	PIPESTATUS[0]=0
   5683 	8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
   5684 ---
   5685 name: persist-history-1
   5686 description:
   5687 	Check if persistent history saving works
   5688 category: !no-histfile
   5689 need-ctty: yes
   5690 arguments: !-i!
   5691 env-setup: !ENV=./Env!HISTFILE=hist.file!
   5692 file-setup: file 644 "Env"
   5693 	PS1=X
   5694 stdin:
   5695 	cat hist.file
   5696 expected-stdout-pattern:
   5697 	/cat hist.file/
   5698 expected-stderr-pattern:
   5699 	/^X*$/
   5700 ---
   5701 name: typeset-1
   5702 description:
   5703 	Check that global does what typeset is supposed to do
   5704 stdin:
   5705 	set -A arrfoo 65
   5706 	foo() {
   5707 		global -Uui16 arrfoo[*]
   5708 	}
   5709 	echo before ${arrfoo[0]} .
   5710 	foo
   5711 	echo after ${arrfoo[0]} .
   5712 	set -A arrbar 65
   5713 	bar() {
   5714 		echo inside before ${arrbar[0]} .
   5715 		arrbar[0]=97
   5716 		echo inside changed ${arrbar[0]} .
   5717 		global -Uui16 arrbar[*]
   5718 		echo inside typeset ${arrbar[0]} .
   5719 		arrbar[0]=48
   5720 		echo inside changed ${arrbar[0]} .
   5721 	}
   5722 	echo before ${arrbar[0]} .
   5723 	bar
   5724 	echo after ${arrbar[0]} .
   5725 expected-stdout:
   5726 	before 65 .
   5727 	after 16#41 .
   5728 	before 65 .
   5729 	inside before 65 .
   5730 	inside changed 97 .
   5731 	inside typeset 16#61 .
   5732 	inside changed 16#30 .
   5733 	after 16#30 .
   5734 ---
   5735 name: typeset-padding-1
   5736 description:
   5737 	Check if left/right justification works as per TFM
   5738 stdin:
   5739 	typeset -L10 ln=0hall0
   5740 	typeset -R10 rn=0hall0
   5741 	typeset -ZL10 lz=0hall0
   5742 	typeset -ZR10 rz=0hall0
   5743 	typeset -Z10 rx=" hallo "
   5744 	echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
   5745 expected-stdout:
   5746 	<0hall0    > <    0hall0> <hall0     > <00000hall0> <0000 hallo>
   5747 ---
   5748 name: typeset-padding-2
   5749 description:
   5750 	Check if base-!10 integers are padded right
   5751 stdin:
   5752 	typeset -Uui16 -L9 ln=16#1
   5753 	typeset -Uui16 -R9 rn=16#1
   5754 	typeset -Uui16 -Z9 zn=16#1
   5755 	typeset -L9 ls=16#1
   5756 	typeset -R9 rs=16#1
   5757 	typeset -Z9 zs=16#1
   5758 	echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
   5759 expected-stdout:
   5760 	<16#1     > <     16#1> <16#000001> <16#1     > <     16#1> <0000016#1>
   5761 ---
   5762 name: utf8bom-1
   5763 description:
   5764 	Check that the UTF-8 Byte Order Mark is ignored as the first
   5765 	multibyte character of the shell input (with -c, from standard
   5766 	input, as file, or as eval argument), but nowhere else
   5767 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
   5768 category: !os:darwin
   5769 stdin:
   5770 	mkdir foo
   5771 	print '#!/bin/sh\necho ohne' >foo/fnord
   5772 	print '#!/bin/sh\necho mit' >foo/fnord
   5773 	print 'fnord\nfnord\nfnord\nfnord' >foo/bar
   5774 	print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
   5775 	set -A anzahl -- foo/*
   5776 	echo got ${#anzahl[*]} files
   5777 	chmod +x foo/*
   5778 	export PATH=$(pwd)/foo:$PATH
   5779 	"$__progname" -c 'fnord'
   5780 	echo =
   5781 	"$__progname" -c 'fnord; fnord; fnord; fnord'
   5782 	echo =
   5783 	"$__progname" foo/bar
   5784 	echo =
   5785 	"$__progname" <foo/bar
   5786 	echo =
   5787 	"$__progname" foo/zoo
   5788 	echo =
   5789 	"$__progname" -c 'echo : $(fnord)'
   5790 	rm -rf foo
   5791 expected-stdout:
   5792 	got 4 files
   5793 	ohne
   5794 	=
   5795 	ohne
   5796 	ohne
   5797 	mit
   5798 	ohne
   5799 	=
   5800 	ohne
   5801 	ohne
   5802 	mit
   5803 	ohne
   5804 	=
   5805 	ohne
   5806 	ohne
   5807 	mit
   5808 	ohne
   5809 	=
   5810 	ohne
   5811 	ohne
   5812 	mit
   5813 	ohne
   5814 	=
   5815 	: ohne
   5816 ---
   5817 name: utf8bom-2
   5818 description:
   5819 	Check that we can execute BOM-shebangs (failures not fatal)
   5820 	XXX if the OS can already execute them, we lose
   5821 	note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
   5822 	note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
   5823 need-pass: no
   5824 category: !os:cygwin,!os:uwin-nt,!os:ultrix,!smksh
   5825 env-setup: !FOO=BAR!
   5826 stdin:
   5827 	print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
   5828 	print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
   5829 	print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
   5830 	print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
   5831 	chmod +x t?
   5832 	./t1
   5833 	./t2
   5834 	./t3
   5835 	./t4
   5836 expected-stdout:
   5837 	1 a=/nonexistant{FOO}
   5838 	2 a=/nonexistant{FOO}
   5839 	3 a=BAR
   5840 	4 a=BAR
   5841 expected-stderr-pattern:
   5842 	/(Unrecognized character .... ignored at \..t4 line 1)*/
   5843 ---
   5844 name: utf8bom-3
   5845 description:
   5846 	Reading the UTF-8 BOM should enable the utf8-mode flag
   5847 	(temporarily for COMSUBs)
   5848 stdin:
   5849 	"$__progname" -c ':; if [[ $- = *U* ]]; then echo 1 on; else echo 1 off; fi'
   5850 	"$__progname" -c ':; if [[ $- = *U* ]]; then echo 2 on; else echo 2 off; fi'
   5851 	"$__progname" -c 'if [[ $- = *U* ]]; then echo 3 on; else echo 3 off; fi; x=$(:; if [[ $- = *U* ]]; then echo 4 on; else echo 4 off; fi); echo $x; if [[ $- = *U* ]]; then echo 5 on; else echo 5 off; fi'
   5852 expected-stdout:
   5853 	1 off
   5854 	2 on
   5855 	3 off
   5856 	4 on
   5857 	5 off
   5858 ---
   5859 name: utf8opt-1a
   5860 description:
   5861 	Check that the utf8-mode flag is not set at non-interactive startup
   5862 category: !os:hpux
   5863 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
   5864 stdin:
   5865 	if [[ $- = *U* ]]; then
   5866 		echo is set
   5867 	else
   5868 		echo is not set
   5869 	fi
   5870 expected-stdout:
   5871 	is not set
   5872 ---
   5873 name: utf8opt-1b
   5874 description:
   5875 	Check that the utf8-mode flag is not set at non-interactive startup
   5876 category: os:hpux
   5877 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
   5878 stdin:
   5879 	if [[ $- = *U* ]]; then
   5880 		echo is set
   5881 	else
   5882 		echo is not set
   5883 	fi
   5884 expected-stdout:
   5885 	is not set
   5886 ---
   5887 name: utf8opt-2a
   5888 description:
   5889 	Check that the utf8-mode flag is set at interactive startup.
   5890 	-DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
   5891 	-DMKSH_ASSUME_UTF8=1 => not expected, please investigate
   5892 	-UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
   5893 	 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
   5894 need-pass: no
   5895 category: !os:hpux
   5896 need-ctty: yes
   5897 arguments: !-i!
   5898 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
   5899 stdin:
   5900 	if [[ $- = *U* ]]; then
   5901 		echo is set
   5902 	else
   5903 		echo is not set
   5904 	fi
   5905 expected-stdout:
   5906 	is set
   5907 expected-stderr-pattern:
   5908 	/(# )*/
   5909 ---
   5910 name: utf8opt-2b
   5911 description:
   5912 	Check that the utf8-mode flag is set at interactive startup
   5913 	Expected failure if -DMKSH_ASSUME_UTF8=0
   5914 category: os:hpux
   5915 need-ctty: yes
   5916 arguments: !-i!
   5917 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
   5918 stdin:
   5919 	if [[ $- = *U* ]]; then
   5920 		echo is set
   5921 	else
   5922 		echo is not set
   5923 	fi
   5924 expected-stdout:
   5925 	is set
   5926 expected-stderr-pattern:
   5927 	/(# )*/
   5928 ---
   5929 name: utf8opt-3a
   5930 description:
   5931 	Ensure U on the command line is honoured
   5932 	(these two tests may pass falsely depending on CPPFLAGS)
   5933 stdin:
   5934 	export i=0
   5935 	code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
   5936 	let i++; "$__progname" -U -c "$code"
   5937 	let i++; "$__progname" +U -c "$code"
   5938 	echo $((++i)) done
   5939 expected-stdout:
   5940 	1 on
   5941 	2 off
   5942 	3 done
   5943 ---
   5944 name: utf8opt-3b
   5945 description:
   5946 	Ensure U on the command line is honoured, interactive shells
   5947 need-ctty: yes
   5948 stdin:
   5949 	export i=0
   5950 	code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
   5951 	let i++; "$__progname" -U -ic "$code"
   5952 	let i++; "$__progname" +U -ic "$code"
   5953 	echo $((++i)) done
   5954 expected-stdout:
   5955 	1 on
   5956 	2 off
   5957 	3 done
   5958 ---
   5959 name: aliases-1
   5960 description:
   5961 	Check if built-in shell aliases are okay
   5962 category: !android,!arge
   5963 stdin:
   5964 	alias
   5965 	typeset -f
   5966 expected-stdout:
   5967 	autoload='typeset -fu'
   5968 	functions='typeset -f'
   5969 	hash='alias -t'
   5970 	history='fc -l'
   5971 	integer='typeset -i'
   5972 	local=typeset
   5973 	login='exec login'
   5974 	nameref='typeset -n'
   5975 	nohup='nohup '
   5976 	r='fc -e -'
   5977 	source='PATH=$PATH:. command .'
   5978 	stop='kill -STOP'
   5979 	suspend='kill -STOP $$'
   5980 	type='whence -v'
   5981 ---
   5982 name: aliases-1-hartz4
   5983 description:
   5984 	Check if built-in shell aliases are okay
   5985 category: android,arge
   5986 stdin:
   5987 	alias
   5988 	typeset -f
   5989 expected-stdout:
   5990 	autoload='typeset -fu'
   5991 	functions='typeset -f'
   5992 	hash='alias -t'
   5993 	history='fc -l'
   5994 	integer='typeset -i'
   5995 	local=typeset
   5996 	login='exec login'
   5997 	nameref='typeset -n'
   5998 	nohup='nohup '
   5999 	r='fc -e -'
   6000 	source='PATH=$PATH:. command .'
   6001 	type='whence -v'
   6002 ---
   6003 name: aliases-2a
   6004 description:
   6005 	Check if set -o sh disables built-in aliases (except a few)
   6006 category: disabled
   6007 arguments: !-o!sh!
   6008 stdin:
   6009 	alias
   6010 	typeset -f
   6011 expected-stdout:
   6012 	integer='typeset -i'
   6013 	local=typeset
   6014 ---
   6015 name: aliases-3a
   6016 description:
   6017 	Check if running as sh disables built-in aliases (except a few)
   6018 category: disabled
   6019 stdin:
   6020 	cp "$__progname" sh
   6021 	./sh -c 'alias; typeset -f'
   6022 	rm -f sh
   6023 expected-stdout:
   6024 	integer='typeset -i'
   6025 	local=typeset
   6026 ---
   6027 name: aliases-2b
   6028 description:
   6029 	Check if set -o sh does not influence built-in aliases
   6030 category: !android,!arge
   6031 arguments: !-o!sh!
   6032 stdin:
   6033 	alias
   6034 	typeset -f
   6035 expected-stdout:
   6036 	autoload='typeset -fu'
   6037 	functions='typeset -f'
   6038 	hash='alias -t'
   6039 	history='fc -l'
   6040 	integer='typeset -i'
   6041 	local=typeset
   6042 	login='exec login'
   6043 	nameref='typeset -n'
   6044 	nohup='nohup '
   6045 	r='fc -e -'
   6046 	source='PATH=$PATH:. command .'
   6047 	stop='kill -STOP'
   6048 	suspend='kill -STOP $$'
   6049 	type='whence -v'
   6050 ---
   6051 name: aliases-3b
   6052 description:
   6053 	Check if running as sh does not influence built-in aliases
   6054 category: !android,!arge
   6055 stdin:
   6056 	cp "$__progname" sh
   6057 	./sh -c 'alias; typeset -f'
   6058 	rm -f sh
   6059 expected-stdout:
   6060 	autoload='typeset -fu'
   6061 	functions='typeset -f'
   6062 	hash='alias -t'
   6063 	history='fc -l'
   6064 	integer='typeset -i'
   6065 	local=typeset
   6066 	login='exec login'
   6067 	nameref='typeset -n'
   6068 	nohup='nohup '
   6069 	r='fc -e -'
   6070 	source='PATH=$PATH:. command .'
   6071 	stop='kill -STOP'
   6072 	suspend='kill -STOP $$'
   6073 	type='whence -v'
   6074 ---
   6075 name: aliases-2b-hartz4
   6076 description:
   6077 	Check if set -o sh does not influence built-in aliases
   6078 category: android,arge
   6079 arguments: !-o!sh!
   6080 stdin:
   6081 	alias
   6082 	typeset -f
   6083 expected-stdout:
   6084 	autoload='typeset -fu'
   6085 	functions='typeset -f'
   6086 	hash='alias -t'
   6087 	history='fc -l'
   6088 	integer='typeset -i'
   6089 	local=typeset
   6090 	login='exec login'
   6091 	nameref='typeset -n'
   6092 	nohup='nohup '
   6093 	r='fc -e -'
   6094 	source='PATH=$PATH:. command .'
   6095 	type='whence -v'
   6096 ---
   6097 name: aliases-3b-hartz4
   6098 description:
   6099 	Check if running as sh does not influence built-in aliases
   6100 category: android,arge
   6101 stdin:
   6102 	cp "$__progname" sh
   6103 	./sh -c 'alias; typeset -f'
   6104 	rm -f sh
   6105 expected-stdout:
   6106 	autoload='typeset -fu'
   6107 	functions='typeset -f'
   6108 	hash='alias -t'
   6109 	history='fc -l'
   6110 	integer='typeset -i'
   6111 	local=typeset
   6112 	login='exec login'
   6113 	nameref='typeset -n'
   6114 	nohup='nohup '
   6115 	r='fc -e -'
   6116 	source='PATH=$PATH:. command .'
   6117 	type='whence -v'
   6118 ---
   6119 name: aliases-funcdef-1
   6120 description:
   6121 	Check if POSIX functions take precedences over aliases
   6122 stdin:
   6123 	alias foo='echo makro'
   6124 	foo() {
   6125 		echo funktion
   6126 	}
   6127 	foo
   6128 expected-stdout:
   6129 	funktion
   6130 ---
   6131 name: aliases-funcdef-2
   6132 description:
   6133 	Check if POSIX functions take precedences over aliases
   6134 stdin:
   6135 	alias foo='echo makro'
   6136 	foo () {
   6137 		echo funktion
   6138 	}
   6139 	foo
   6140 expected-stdout:
   6141 	funktion
   6142 ---
   6143 name: aliases-funcdef-3
   6144 description:
   6145 	Check if aliases take precedences over Korn functions
   6146 stdin:
   6147 	alias foo='echo makro'
   6148 	function foo {
   6149 		echo funktion
   6150 	}
   6151 	foo
   6152 expected-stdout:
   6153 	makro
   6154 ---
   6155 name: aliases-funcdef-4
   6156 description:
   6157 	Functions should only take over if actually being defined
   6158 stdin:
   6159 	alias local
   6160 	:|| local() { :; }
   6161 	alias local
   6162 expected-stdout:
   6163 	local=typeset
   6164 	local=typeset
   6165 ---
   6166 name: arrays-1
   6167 description:
   6168 	Check if Korn Shell arrays work as expected
   6169 stdin:
   6170 	v="c d"
   6171 	set -A foo -- a \$v "$v" '$v' b
   6172 	echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
   6173 expected-stdout:
   6174 	5|a|$v|c d|$v|b|
   6175 ---
   6176 name: arrays-2a
   6177 description:
   6178 	Check if bash-style arrays work as expected
   6179 category: !smksh
   6180 stdin:
   6181 	v="c d"
   6182 	foo=(a \$v "$v" '$v' b)
   6183 	echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
   6184 expected-stdout:
   6185 	5|a|$v|c d|$v|b|
   6186 ---
   6187 name: arrays-2b
   6188 description:
   6189 	Check if bash-style arrays work as expected, with newlines
   6190 category: !smksh
   6191 stdin:
   6192 	test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
   6193 	v="e f"
   6194 	foo=(a
   6195 		bc
   6196 		d \$v "$v" '$v' g
   6197 	)
   6198 	printf '%s|' "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
   6199 	foo=(a\
   6200 		bc
   6201 		d \$v "$v" '$v' g
   6202 	)
   6203 	printf '%s|' "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
   6204 	foo=(a\
   6205 	bc\\
   6206 		d \$v "$v" '$v'
   6207 	g)
   6208 	printf '%s|' "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
   6209 expected-stdout:
   6210 	7|a|bc|d|$v|e f|$v|g|
   6211 	7|a|bc|d|$v|e f|$v|g|
   6212 	6|abc\|d|$v|e f|$v|g||
   6213 ---
   6214 name: arrays-3
   6215 description:
   6216 	Check if array bounds are uint32_t
   6217 stdin:
   6218 	set -A foo a b c
   6219 	foo[4097]=d
   6220 	foo[2147483637]=e
   6221 	echo ${foo[*]}
   6222 	foo[-1]=f
   6223 	echo ${foo[4294967295]} g ${foo[*]}
   6224 expected-stdout:
   6225 	a b c d e
   6226 	f g a b c d e f
   6227 ---
   6228 name: arrays-4
   6229 description:
   6230 	Check if Korn Shell arrays with specified indices work as expected
   6231 category: !smksh
   6232 stdin:
   6233 	v="c d"
   6234 	set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
   6235 	echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
   6236 expected-stdout:
   6237 	5|a|$v|c d||$v|b|
   6238 ---
   6239 name: arrays-5
   6240 description:
   6241 	Check if bash-style arrays with specified indices work as expected
   6242 category: !smksh
   6243 stdin:
   6244 	v="c d"
   6245 	foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
   6246 	echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
   6247 	x=([128]=foo bar baz)
   6248 	echo k= ${!x[*]} .
   6249 	echo v= ${x[*]} .
   6250 expected-stdout:
   6251 	5|a|$v|c d||$v|b|
   6252 	k= 128 129 130 .
   6253 	v= foo bar baz .
   6254 ---
   6255 name: arrays-6
   6256 description:
   6257 	Check if we can get the array keys (indices) for indexed arrays,
   6258 	Korn shell style
   6259 stdin:
   6260 	of() {
   6261 		i=0
   6262 		for x in "$@"; do
   6263 			echo -n "$((i++))<$x>"
   6264 		done
   6265 		echo
   6266 	}
   6267 	foo[1]=eins
   6268 	set | grep '^foo'
   6269 	echo =
   6270 	foo[0]=zwei
   6271 	foo[4]=drei
   6272 	set | grep '^foo'
   6273 	echo =
   6274 	echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
   6275 	echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
   6276 	echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
   6277 	echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
   6278 	echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
   6279 	echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
   6280 	echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
   6281 	echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
   6282 expected-stdout:
   6283 	foo[1]=eins
   6284 	=
   6285 	foo[0]=zwei
   6286 	foo[1]=eins
   6287 	foo[4]=drei
   6288 	=
   6289 	a 0<zwei>1<eins>2<drei> = a
   6290 	b 0<zwei eins drei> = 0<> b
   6291 	c 0<zwei>1<eins>2<drei> = c
   6292 	d 0<zwei>1<eins>2<drei> = d
   6293 	e 0<0>1<1>2<4> = e
   6294 	f 0<0 1 4> = 0<> f
   6295 	g 0<0>1<1>2<4> = g
   6296 	h 0<0>1<1>2<4> = h
   6297 ---
   6298 name: arrays-7
   6299 description:
   6300 	Check if we can get the array keys (indices) for indexed arrays,
   6301 	Korn shell style, in some corner cases
   6302 stdin:
   6303 	echo !arz: ${!arz}
   6304 	echo !arz[0]: ${!arz[0]}
   6305 	echo !arz[1]: ${!arz[1]}
   6306 	arz=foo
   6307 	echo !arz: ${!arz}
   6308 	echo !arz[0]: ${!arz[0]}
   6309 	echo !arz[1]: ${!arz[1]}
   6310 	unset arz
   6311 	echo !arz: ${!arz}
   6312 	echo !arz[0]: ${!arz[0]}
   6313 	echo !arz[1]: ${!arz[1]}
   6314 expected-stdout:
   6315 	!arz: 0
   6316 	!arz[0]:
   6317 	!arz[1]:
   6318 	!arz: arz
   6319 	!arz[0]: 0
   6320 	!arz[1]:
   6321 	!arz: 0
   6322 	!arz[0]:
   6323 	!arz[1]:
   6324 ---
   6325 name: arrays-8
   6326 description:
   6327 	Check some behavioural rules for arrays.
   6328 stdin:
   6329 	fna() {
   6330 		set -A aa 9
   6331 	}
   6332 	fnb() {
   6333 		typeset ab
   6334 		set -A ab 9
   6335 	}
   6336 	fnc() {
   6337 		typeset ac
   6338 		set -A ac 91
   6339 		unset ac
   6340 		set -A ac 92
   6341 	}
   6342 	fnd() {
   6343 		set +A ad 9
   6344 	}
   6345 	fne() {
   6346 		unset ae
   6347 		set +A ae 9
   6348 	}
   6349 	fnf() {
   6350 		unset af[0]
   6351 		set +A af 9
   6352 	}
   6353 	fng() {
   6354 		unset ag[*]
   6355 		set +A ag 9
   6356 	}
   6357 	set -A aa 1 2
   6358 	set -A ab 1 2
   6359 	set -A ac 1 2
   6360 	set -A ad 1 2
   6361 	set -A ae 1 2
   6362 	set -A af 1 2
   6363 	set -A ag 1 2
   6364 	set -A ah 1 2
   6365 	typeset -Z3 aa ab ac ad ae af ag
   6366 	print 1a ${aa[*]} .
   6367 	print 1b ${ab[*]} .
   6368 	print 1c ${ac[*]} .
   6369 	print 1d ${ad[*]} .
   6370 	print 1e ${ae[*]} .
   6371 	print 1f ${af[*]} .
   6372 	print 1g ${ag[*]} .
   6373 	print 1h ${ah[*]} .
   6374 	fna
   6375 	fnb
   6376 	fnc
   6377 	fnd
   6378 	fne
   6379 	fnf
   6380 	fng
   6381 	typeset -Z5 ah[*]
   6382 	print 2a ${aa[*]} .
   6383 	print 2b ${ab[*]} .
   6384 	print 2c ${ac[*]} .
   6385 	print 2d ${ad[*]} .
   6386 	print 2e ${ae[*]} .
   6387 	print 2f ${af[*]} .
   6388 	print 2g ${ag[*]} .
   6389 	print 2h ${ah[*]} .
   6390 expected-stdout:
   6391 	1a 001 002 .
   6392 	1b 001 002 .
   6393 	1c 001 002 .
   6394 	1d 001 002 .
   6395 	1e 001 002 .
   6396 	1f 001 002 .
   6397 	1g 001 002 .
   6398 	1h 1 2 .
   6399 	2a 9 .
   6400 	2b 001 002 .
   6401 	2c 92 .
   6402 	2d 009 002 .
   6403 	2e 9 .
   6404 	2f 9 002 .
   6405 	2g 009 .
   6406 	2h 00001 00002 .
   6407 ---
   6408 name: arrays-9a
   6409 description:
   6410 	Check that we can concatenate arrays
   6411 category: !smksh
   6412 stdin:
   6413 	unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
   6414 	unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
   6415 	unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
   6416 expected-stdout:
   6417 	1 0 1 : bar baz .
   6418 	2 0 1 2 : foo bar baz .
   6419 	3 0 2 3 5 : bar foo baz quux .
   6420 ---
   6421 name: arrays-9b
   6422 description:
   6423 	Check that we can concatenate parameters too
   6424 stdin:
   6425 	unset foo; foo=bar; foo+=baz; echo 1 $foo .
   6426 	unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
   6427 expected-stdout:
   6428 	1 barbaz .
   6429 	2 16#a20 .
   6430 ---
   6431 name: varexpand-substr-1
   6432 description:
   6433 	Check if bash-style substring expansion works
   6434 	when using positive numerics
   6435 stdin:
   6436 	x=abcdefghi
   6437 	typeset -i y=123456789
   6438 	typeset -i 16 z=123456789	# 16#75bcd15
   6439 	echo a t${x:2:2} ${y:2:3} ${z:2:3} a
   6440 	echo b ${x::3} ${y::3} ${z::3} b
   6441 	echo c ${x:2:} ${y:2:} ${z:2:} c
   6442 	echo d ${x:2} ${y:2} ${z:2} d
   6443 	echo e ${x:2:6} ${y:2:6} ${z:2:7} e
   6444 	echo f ${x:2:7} ${y:2:7} ${z:2:8} f
   6445 	echo g ${x:2:8} ${y:2:8} ${z:2:9} g
   6446 expected-stdout:
   6447 	a tcd 345 #75 a
   6448 	b abc 123 16# b
   6449 	c c
   6450 	d cdefghi 3456789 #75bcd15 d
   6451 	e cdefgh 345678 #75bcd1 e
   6452 	f cdefghi 3456789 #75bcd15 f
   6453 	g cdefghi 3456789 #75bcd15 g
   6454 ---
   6455 name: varexpand-substr-2
   6456 description:
   6457 	Check if bash-style substring expansion works
   6458 	when using negative numerics or expressions
   6459 stdin:
   6460 	x=abcdefghi
   6461 	typeset -i y=123456789
   6462 	typeset -i 16 z=123456789	# 16#75bcd15
   6463 	n=2
   6464 	echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
   6465 	echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
   6466 	echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
   6467 	echo d t${x: n:2} ${y: n:3} ${z: n:3} d
   6468 expected-stdout:
   6469 	a cde 345 #75 a
   6470 	b cde 345 #75 b
   6471 	c h 8 1 c
   6472 	d tcd 345 #75 d
   6473 ---
   6474 name: varexpand-substr-3
   6475 description:
   6476 	Check that some things that work in bash fail.
   6477 	This is by design. And that some things fail in both.
   6478 stdin:
   6479 	export x=abcdefghi n=2
   6480 	"$__progname" -c 'echo v${x:(n)}x'
   6481 	"$__progname" -c 'echo w${x: n}x'
   6482 	"$__progname" -c 'echo x${x:n}x'
   6483 	"$__progname" -c 'echo y${x:}x'
   6484 	"$__progname" -c 'echo z${x}x'
   6485 	"$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
   6486 expected-stdout:
   6487 	vcdefghix
   6488 	wcdefghix
   6489 	zabcdefghix
   6490 	1
   6491 expected-stderr-pattern:
   6492 	/x:n.*bad substitution.*\n.*bad substitution/
   6493 ---
   6494 name: varexpand-substr-4
   6495 description:
   6496 	Check corner cases for substring expansion
   6497 stdin:
   6498 	x=abcdefghi
   6499 	integer y=2
   6500 	echo a ${x:(y == 1 ? 2 : 3):4} a
   6501 expected-stdout:
   6502 	a defg a
   6503 ---
   6504 name: varexpand-substr-5A
   6505 description:
   6506 	Check that substring expansions work on characters
   6507 stdin:
   6508 	set +U
   6509 	x=mh
   6510 	echo a ${x::1} ${x: -1} a
   6511 	echo b ${x::3} ${x: -3} b
   6512 	echo c ${x:1:2} ${x: -3:2} c
   6513 	echo d ${#x} d
   6514 expected-stdout:
   6515 	a m h a
   6516 	b m h b
   6517 	c   c
   6518 	d 4 d
   6519 ---
   6520 name: varexpand-substr-5W
   6521 description:
   6522 	Check that substring expansions work on characters
   6523 stdin:
   6524 	set -U
   6525 	x=mh
   6526 	echo a ${x::1} ${x: -1} a
   6527 	echo b ${x::2} ${x: -2} b
   6528 	echo c ${x:1:1} ${x: -2:1} c
   6529 	echo d ${#x} d
   6530 expected-stdout:
   6531 	a m h a
   6532 	b m h b
   6533 	c   c
   6534 	d 3 d
   6535 ---
   6536 name: varexpand-substr-6
   6537 description:
   6538 	Check that string substitution works correctly
   6539 stdin:
   6540 	foo=1
   6541 	bar=2
   6542 	baz=qwertyuiop
   6543 	echo a ${baz: foo: bar}
   6544 	echo b ${baz: foo: $bar}
   6545 	echo c ${baz: $foo: bar}
   6546 	echo d ${baz: $foo: $bar}
   6547 expected-stdout:
   6548 	a we
   6549 	b we
   6550 	c we
   6551 	d we
   6552 ---
   6553 name: varexpand-special-hash
   6554 description:
   6555 	Check special ${var@x} expansion for x=hash
   6556 stdin:
   6557 	typeset -i8 foo=10
   6558 	bar=baz
   6559 	unset baz
   6560 	print ${foo@#} ${bar@#} ${baz@#} .
   6561 expected-stdout:
   6562 	D50219A0 20E5DB5B 00000001 .
   6563 ---
   6564 name: varexpand-null-1
   6565 description:
   6566 	Ensure empty strings expand emptily
   6567 stdin:
   6568 	print x ${a} ${b} y
   6569 	print z ${a#?} ${b%?} w
   6570 	print v ${a=} ${b/c/d} u
   6571 expected-stdout:
   6572 	x y
   6573 	z w
   6574 	v u
   6575 ---
   6576 name: varexpand-null-2
   6577 description:
   6578 	Ensure empty strings, when quoted, are expanded as empty strings
   6579 stdin:
   6580 	printf '<%s> ' 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
   6581 	echo .
   6582 expected-stdout:
   6583 	<1> <> <2> <> <+> <> <3> <> <+> <> .
   6584 ---
   6585 name: print-funny-chars
   6586 description:
   6587 	Check print builtin's capability to output designated characters
   6588 stdin:
   6589 	print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
   6590 expected-stdout:
   6591 	<d@>
   6592 ---
   6593 name: print-bksl-c
   6594 description:
   6595 	Check print builtin's \c escape
   6596 stdin:
   6597 	print '\ca'; print b
   6598 expected-stdout:
   6599 	ab
   6600 ---
   6601 name: print-nul-chars
   6602 description:
   6603 	Check handling of NUL characters for print and read
   6604 	note: second line should output 4 3 but we cannot
   6605 	handle NUL characters in strings yet
   6606 stdin:
   6607 	print $(($(print '<\0>' | wc -c)))
   6608 	x=$(print '<\0>')
   6609 	print $(($(print "$x" | wc -c))) ${#x}
   6610 expected-stdout:
   6611 	4
   6612 	3 2
   6613 ---
   6614 name: print-escapes
   6615 description:
   6616 	Check backslash expansion by the print builtin
   6617 stdin:
   6618 	print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
   6619 	    '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
   6620 	    '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b  \d\e\f\g\h\i\j\k\l\m\n\o\p' \
   6621 	    '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
   6622 	    '\0x' '\0123' '\01234' | {
   6623 		# integer-base-one-3As
   6624 		typeset -Uui16 -Z11 pos=0
   6625 		typeset -Uui16 -Z5 hv=2147483647
   6626 		typeset -i1 wc=0x0A
   6627 		dasc=
   6628 		nl=${wc#1#}
   6629 		while IFS= read -r line; do
   6630 			line=$line$nl
   6631 			while [[ -n $line ]]; do
   6632 				hv=1#${line::1}
   6633 				if (( (pos & 15) == 0 )); then
   6634 					(( pos )) && print "$dasc|"
   6635 					print -n "${pos#16#}  "
   6636 					dasc=' |'
   6637 				fi
   6638 				print -n "${hv#16#} "
   6639 				if (( (hv < 32) || (hv > 126) )); then
   6640 					dasc=$dasc.
   6641 				else
   6642 					dasc=$dasc${line::1}
   6643 				fi
   6644 				(( (pos++ & 15) == 7 )) && print -n -- '- '
   6645 				line=${line:1}
   6646 			done
   6647 		done
   6648 		while (( pos & 15 )); do
   6649 			print -n '   '
   6650 			(( (pos++ & 15) == 7 )) && print -n -- '- '
   6651 		done
   6652 		(( hv == 2147483647 )) || print "$dasc|"
   6653 	}
   6654 expected-stdout:
   6655 	00000000  5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27  |\ \!\"\#\$\%\&\'|
   6656 	00000010  5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F  |\(\)\*\+\,\-\.\/|
   6657 	00000020  5C 31 5C 32 5C 33 5C 34 - 5C 35 5C 36 5C 37 5C 38  |\1\2\3\4\5\6\7\8|
   6658 	00000030  20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C  | \9\:\;\<\=\>\?\|
   6659 	00000040  40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48  |@\A\B\C\D.\F\G\H|
   6660 	00000050  5C 49 5C 4A 5C 4B 5C 4C - 5C 4D 5C 4E 5C 4F 5C 50  |\I\J\K\L\M\N\O\P|
   6661 	00000060  5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C  |\Q\R\S\T \V\W\X\|
   6662 	00000070  59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08  |Y\Z\[\]\^\_\`..|
   6663 	00000080  20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B  |  \d..\g\h\i\j\k|
   6664 	00000090  5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09  |\l\m.\o\p \q.\s.|
   6665 	000000A0  0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20  |.\w\y\z\{\|\}\~ |
   6666 	000000B0  E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20  |...d ... .3 x S |
   6667 	000000C0  53 34 0A                -                          |S4.|
   6668 ---
   6669 name: dollar-doublequoted-strings
   6670 description:
   6671 	Check that a $ preceding "" is ignored
   6672 stdin:
   6673 	echo $"Localise me!"
   6674 	cat <<<$"Me too!"
   6675 	V=X
   6676 	aol=aol
   6677 	cat <<-$"aol"
   6678 		I do not take a $V for a V!
   6679 	aol
   6680 expected-stdout:
   6681 	Localise me!
   6682 	Me too!
   6683 	I do not take a $V for a V!
   6684 ---
   6685 name: dollar-quoted-strings
   6686 description:
   6687 	Check backslash expansion by $'' strings
   6688 stdin:
   6689 	printf '%s\n' $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
   6690 	    $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
   6691 	    $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
   6692 	    $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
   6693 	    $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
   6694 	    $'\2345' $'\ca' $'\c!' $'\c?' $'\c' $'a\
   6695 	b' | {
   6696 		# integer-base-one-3As
   6697 		typeset -Uui16 -Z11 pos=0
   6698 		typeset -Uui16 -Z5 hv=2147483647
   6699 		typeset -i1 wc=0x0A
   6700 		dasc=
   6701 		nl=${wc#1#}
   6702 		while IFS= read -r line; do
   6703 			line=$line$nl
   6704 			while [[ -n $line ]]; do
   6705 				hv=1#${line::1}
   6706 				if (( (pos & 15) == 0 )); then
   6707 					(( pos )) && print "$dasc|"
   6708 					print -n "${pos#16#}  "
   6709 					dasc=' |'
   6710 				fi
   6711 				print -n "${hv#16#} "
   6712 				if (( (hv < 32) || (hv > 126) )); then
   6713 					dasc=$dasc.
   6714 				else
   6715 					dasc=$dasc${line::1}
   6716 				fi
   6717 				(( (pos++ & 15) == 7 )) && print -n -- '- '
   6718 				line=${line:1}
   6719 			done
   6720 		done
   6721 		while (( pos & 15 )); do
   6722 			print -n '   '
   6723 			(( (pos++ & 15) == 7 )) && print -n -- '- '
   6724 		done
   6725 		(( hv == 2147483647 )) || print "$dasc|"
   6726 	}
   6727 expected-stdout:
   6728 	00000000  20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F  | !"#$%&'()*+,-./|
   6729 	00000010  20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38  | .......a.a.b..8|
   6730 	00000020  39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48  |9:;<=>?@ABCD.FGH|
   6731 	00000030  49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57  |I.JKLMNOPQRST.VW|
   6732 	00000040  58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67  |XYZ[\]^_`..d...g|
   6733 	00000050  68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77  |hijklm.opq.s...w|
   6734 	00000060  01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A  |.yz{|}~ $x....d.|
   6735 	00000070  EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C  |.......fn..4....|
   6736 	00000080  35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A  |5...........a.b.|
   6737 ---
   6738 name: dollar-quotes-in-heredocs
   6739 description:
   6740 	They are, however, not parsed in here documents
   6741 stdin:
   6742 	cat <<EOF
   6743 		dollar = strchr(s, '$');	/* ' */
   6744 	EOF
   6745 	cat <<$'a\tb'
   6746 	a\tb
   6747 	a	b
   6748 expected-stdout:
   6749 		dollar = strchr(s, '$');	/* ' */
   6750 	a\tb
   6751 ---
   6752 name: dollar-quotes-in-herestrings
   6753 description:
   6754 	They are, not parsed in here strings either
   6755 stdin:
   6756 	cat <<<"dollar = strchr(s, '$');	/* ' */"
   6757 	cat <<<'dollar = strchr(s, '\''$'\'');	/* '\'' */'
   6758 	x="dollar = strchr(s, '$');	/* ' */"
   6759 	cat <<<"$x"
   6760 	cat <<<$'a\E[0m\tb'
   6761 expected-stdout:
   6762 	dollar = strchr(s, '$');	/* ' */
   6763 	dollar = strchr(s, '$');	/* ' */
   6764 	dollar = strchr(s, '$');	/* ' */
   6765 	a[0m	b
   6766 ---
   6767 name: dot-needs-argument
   6768 description:
   6769 	check Debian #415167 solution: '.' without arguments should fail
   6770 stdin:
   6771 	"$__progname" -c .
   6772 	"$__progname" -c source
   6773 expected-exit: e != 0
   6774 expected-stderr-pattern:
   6775 	/\.: missing argument.*\n.*\.: missing argument/
   6776 ---
   6777 name: alias-function-no-conflict
   6778 description:
   6779 	make aliases not conflict with functions
   6780 	note: for ksh-like functions, the order of preference is
   6781 	different; bash outputs baz instead of bar in line 2 below
   6782 stdin:
   6783 	alias foo='echo bar'
   6784 	foo() {
   6785 		echo baz
   6786 	}
   6787 	alias korn='echo bar'
   6788 	function korn {
   6789 		echo baz
   6790 	}
   6791 	foo
   6792 	korn
   6793 	unset -f foo
   6794 	foo 2>&- || echo rab
   6795 expected-stdout:
   6796 	baz
   6797 	bar
   6798 	rab
   6799 ---
   6800 name: bash-function-parens
   6801 description:
   6802 	ensure the keyword function is ignored when preceding
   6803 	POSIX style function declarations (bashism)
   6804 stdin:
   6805 	mk() {
   6806 		echo '#!'"$__progname"
   6807 		echo "$1 {"
   6808 		echo '	echo "bar='\''$0'\'\"
   6809 		echo '}'
   6810 		echo ${2:-foo}
   6811 	}
   6812 	mk 'function foo' >f-korn
   6813 	mk 'foo ()' >f-dash
   6814 	mk 'function foo ()' >f-bash
   6815 	mk 'function stop ()' stop >f-stop
   6816 	chmod +x f-*
   6817 	echo "korn: $(./f-korn)"
   6818 	echo "dash: $(./f-dash)"
   6819 	echo "bash: $(./f-bash)"
   6820 	echo "stop: $(./f-stop)"
   6821 expected-stdout:
   6822 	korn: bar='foo'
   6823 	dash: bar='./f-dash'
   6824 	bash: bar='./f-bash'
   6825 	stop: bar='./f-stop'
   6826 ---
   6827 name: integer-base-one-1
   6828 description:
   6829 	check if the use of fake integer base 1 works
   6830 stdin:
   6831 	set -U
   6832 	typeset -Uui16 i0=1# i1=1#
   6833 	typeset -i1 o0a=64
   6834 	typeset -i1 o1a=0x263A
   6835 	typeset -Uui1 o0b=0x7E
   6836 	typeset -Uui1 o1b=0xFDD0
   6837 	integer px=0xCAFE 'p0=1# ' p1=1# pl=1#f
   6838 	echo "in <$i0> <$i1>"
   6839 	echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
   6840 	typeset -Uui1 i0 i1
   6841 	echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
   6842 	typeset -Uui16 tv1=1#~ tv2=1# tv3=1# tv4=1# tv5=1# tv6=1# tv7=1# tv8=1#
   6843 	echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
   6844 	typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
   6845 	echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
   6846 	typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
   6847 	echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
   6848 expected-stdout:
   6849 	in <16#EFEF> <16#20AC>
   6850 	out <@|~> <|>
   6851 	pass <16#cafe> <1# > <1#> <1#f> <|>
   6852 	specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
   6853 	specW <~> <> <> <> <> <> <> <>
   6854 	specU <> <> <>
   6855 ---
   6856 name: integer-base-one-2a
   6857 description:
   6858 	check if the use of fake integer base 1 stops at correct characters
   6859 stdin:
   6860 	set -U
   6861 	integer x=1#foo
   6862 	echo /$x/
   6863 expected-stderr-pattern:
   6864 	/1#foo: unexpected 'oo'/
   6865 expected-exit: e != 0
   6866 ---
   6867 name: integer-base-one-2b
   6868 description:
   6869 	check if the use of fake integer base 1 stops at correct characters
   6870 stdin:
   6871 	set -U
   6872 	integer x=1#
   6873 	echo /$x/
   6874 expected-stderr-pattern:
   6875 	/1#: unexpected ''/
   6876 expected-exit: e != 0
   6877 ---
   6878 name: integer-base-one-2c1
   6879 description:
   6880 	check if the use of fake integer base 1 stops at correct characters
   6881 stdin:
   6882 	set -U
   6883 	integer x=1#
   6884 	echo /$x/
   6885 expected-stdout:
   6886 	/1#/
   6887 ---
   6888 name: integer-base-one-2c2
   6889 description:
   6890 	check if the use of fake integer base 1 stops at correct characters
   6891 stdin:
   6892 	set +U
   6893 	integer x=1#
   6894 	echo /$x/
   6895 expected-stderr-pattern:
   6896 	/1#: unexpected ''/
   6897 expected-exit: e != 0
   6898 ---
   6899 name: integer-base-one-2d1
   6900 description:
   6901 	check if the use of fake integer base 1 handles octets okay
   6902 stdin:
   6903 	set -U
   6904 	typeset -i16 x=1#
   6905 	echo /$x/	# invalid utf-8
   6906 expected-stdout:
   6907 	/16#efff/
   6908 ---
   6909 name: integer-base-one-2d2
   6910 description:
   6911 	check if the use of fake integer base 1 handles octets
   6912 stdin:
   6913 	set -U
   6914 	typeset -i16 x=1#
   6915 	echo /$x/	# invalid 2-byte
   6916 expected-stdout:
   6917 	/16#efc2/
   6918 ---
   6919 name: integer-base-one-2d3
   6920 description:
   6921 	check if the use of fake integer base 1 handles octets
   6922 stdin:
   6923 	set -U
   6924 	typeset -i16 x=1#
   6925 	echo /$x/	# invalid 2-byte
   6926 expected-stdout:
   6927 	/16#efef/
   6928 ---
   6929 name: integer-base-one-2d4
   6930 description:
   6931 	check if the use of fake integer base 1 stops at invalid input
   6932 stdin:
   6933 	set -U
   6934 	typeset -i16 x=1#
   6935 	echo /$x/	# invalid 3-byte
   6936 expected-stderr-pattern:
   6937 	/1#: unexpected ''/
   6938 expected-exit: e != 0
   6939 ---
   6940 name: integer-base-one-2d5
   6941 description:
   6942 	check if the use of fake integer base 1 stops at invalid input
   6943 stdin:
   6944 	set -U
   6945 	typeset -i16 x=1#
   6946 	echo /$x/	# non-minimalistic
   6947 expected-stderr-pattern:
   6948 	/1#: unexpected ''/
   6949 expected-exit: e != 0
   6950 ---
   6951 name: integer-base-one-2d6
   6952 description:
   6953 	check if the use of fake integer base 1 stops at invalid input
   6954 stdin:
   6955 	set -U
   6956 	typeset -i16 x=1#
   6957 	echo /$x/	# non-minimalistic
   6958 expected-stderr-pattern:
   6959 	/1#: unexpected ''/
   6960 expected-exit: e != 0
   6961 ---
   6962 name: integer-base-one-3As
   6963 description:
   6964 	some sample code for hexdumping
   6965 	not NUL safe; input lines must be NL terminated
   6966 stdin:
   6967 	{
   6968 		print 'Hello, World!\\\n'
   6969 		typeset -Uui16 i=0x100
   6970 		# change that to 0xFF once we can handle embedded
   6971 		# NUL characters in strings / here documents
   6972 		while (( i++ < 0x1FF )); do
   6973 			print -n "\x${i#16#1}"
   6974 		done
   6975 		print '\0z'
   6976 	} | {
   6977 		# integer-base-one-3As
   6978 		typeset -Uui16 -Z11 pos=0
   6979 		typeset -Uui16 -Z5 hv=2147483647
   6980 		typeset -i1 wc=0x0A
   6981 		dasc=
   6982 		nl=${wc#1#}
   6983 		while IFS= read -r line; do
   6984 			line=$line$nl
   6985 			while [[ -n $line ]]; do
   6986 				hv=1#${line::1}
   6987 				if (( (pos & 15) == 0 )); then
   6988 					(( pos )) && print "$dasc|"
   6989 					print -n "${pos#16#}  "
   6990 					dasc=' |'
   6991 				fi
   6992 				print -n "${hv#16#} "
   6993 				if (( (hv < 32) || (hv > 126) )); then
   6994 					dasc=$dasc.
   6995 				else
   6996 					dasc=$dasc${line::1}
   6997 				fi
   6998 				(( (pos++ & 15) == 7 )) && print -n -- '- '
   6999 				line=${line:1}
   7000 			done
   7001 		done
   7002 		while (( pos & 15 )); do
   7003 			print -n '   '
   7004 			(( (pos++ & 15) == 7 )) && print -n -- '- '
   7005 		done
   7006 		(( hv == 2147483647 )) || print "$dasc|"
   7007 	}
   7008 expected-stdout:
   7009 	00000000  48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3  |Hello, World!\..|
   7010 	00000010  81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC  |................|
   7011 	00000020  81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E  |................|
   7012 	00000030  0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E  |................|
   7013 	00000040  1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E  |. !"#$%&'()*+,-.|
   7014 	00000050  2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E  |/0123456789:;<=>|
   7015 	00000060  3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E  |?@ABCDEFGHIJKLMN|
   7016 	00000070  4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E  |OPQRSTUVWXYZ[\]^|
   7017 	00000080  5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E  |_`abcdefghijklmn|
   7018 	00000090  6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E  |opqrstuvwxyz{|}~|
   7019 	000000A0  7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E  |................|
   7020 	000000B0  8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E  |................|
   7021 	000000C0  9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE  |................|
   7022 	000000D0  AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE  |................|
   7023 	000000E0  BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE  |................|
   7024 	000000F0  CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE  |................|
   7025 	00000100  DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE  |................|
   7026 	00000110  EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE  |................|
   7027 	00000120  FF 7A 0A                -                          |.z.|
   7028 ---
   7029 name: integer-base-one-3Ws
   7030 description:
   7031 	some sample code for hexdumping Unicode
   7032 	not NUL safe; input lines must be NL terminated
   7033 stdin:
   7034 	set -U
   7035 	{
   7036 		print 'Hello, World!\\\n'
   7037 		typeset -Uui16 i=0x100
   7038 		# change that to 0xFF once we can handle embedded
   7039 		# NUL characters in strings / here documents
   7040 		while (( i++ < 0x1FF )); do
   7041 			print -n "\u${i#16#1}"
   7042 		done
   7043 		print
   7044 		print \\xff		# invalid utf-8
   7045 		print \\xc2		# invalid 2-byte
   7046 		print \\xef\\xbf\\xc0	# invalid 3-byte
   7047 		print \\xc0\\x80	# non-minimalistic
   7048 		print \\xe0\\x80\\x80	# non-minimalistic
   7049 		print ''	# end of range
   7050 		print '\0z'		# embedded NUL
   7051 	} | {
   7052 		# integer-base-one-3Ws
   7053 		typeset -Uui16 -Z11 pos=0
   7054 		typeset -Uui16 -Z7 hv
   7055 		typeset -i1 wc=0x0A
   7056 		typeset -i lpos
   7057 		dasc=
   7058 		nl=${wc#1#}
   7059 		while IFS= read -r line; do
   7060 			line=$line$nl
   7061 			lpos=0
   7062 			while (( lpos < ${#line} )); do
   7063 				wc=1#${line:(lpos++):1}
   7064 				if (( (wc < 32) || \
   7065 				    ((wc > 126) && (wc < 160)) )); then
   7066 					dch=.
   7067 				elif (( (wc & 0xFF80) == 0xEF80 )); then
   7068 					dch=
   7069 				else
   7070 					dch=${wc#1#}
   7071 				fi
   7072 				if (( (pos & 7) == 7 )); then
   7073 					dasc=$dasc$dch
   7074 					dch=
   7075 				elif (( (pos & 7) == 0 )); then
   7076 					(( pos )) && print "$dasc|"
   7077 					print -n "${pos#16#}  "
   7078 					dasc=' |'
   7079 				fi
   7080 				let hv=wc
   7081 				print -n "${hv#16#} "
   7082 				(( (pos++ & 7) == 3 )) && \
   7083 				    print -n -- '- '
   7084 				dasc=$dasc$dch
   7085 			done
   7086 		done
   7087 		while (( pos & 7 )); do
   7088 			print -n '     '
   7089 			(( (pos++ & 7) == 3 )) && print -n -- '- '
   7090 		done
   7091 		(( hv == 2147483647 )) || print "$dasc|"
   7092 	}
   7093 expected-stdout:
   7094 	00000000  0048 0065 006C 006C - 006F 002C 0020 0057  |Hello, W|
   7095 	00000008  006F 0072 006C 0064 - 0021 005C 000A 3053  |orld!\.|
   7096 	00000010  3093 306B 3061 306F - FF01 000A 0001 0002  |...|
   7097 	00000018  0003 0004 0005 0006 - 0007 0008 0009 000A  |........|
   7098 	00000020  000B 000C 000D 000E - 000F 0010 0011 0012  |........|
   7099 	00000028  0013 0014 0015 0016 - 0017 0018 0019 001A  |........|
   7100 	00000030  001B 001C 001D 001E - 001F 0020 0021 0022  |..... !"|
   7101 	00000038  0023 0024 0025 0026 - 0027 0028 0029 002A  |#$%&'()*|
   7102 	00000040  002B 002C 002D 002E - 002F 0030 0031 0032  |+,-./012|
   7103 	00000048  0033 0034 0035 0036 - 0037 0038 0039 003A  |3456789:|
   7104 	00000050  003B 003C 003D 003E - 003F 0040 0041 0042  |;<=>?@AB|
   7105 	00000058  0043 0044 0045 0046 - 0047 0048 0049 004A  |CDEFGHIJ|
   7106 	00000060  004B 004C 004D 004E - 004F 0050 0051 0052  |KLMNOPQR|
   7107 	00000068  0053 0054 0055 0056 - 0057 0058 0059 005A  |STUVWXYZ|
   7108 	00000070  005B 005C 005D 005E - 005F 0060 0061 0062  |[\]^_`ab|
   7109 	00000078  0063 0064 0065 0066 - 0067 0068 0069 006A  |cdefghij|
   7110 	00000080  006B 006C 006D 006E - 006F 0070 0071 0072  |klmnopqr|
   7111 	00000088  0073 0074 0075 0076 - 0077 0078 0079 007A  |stuvwxyz|
   7112 	00000090  007B 007C 007D 007E - 007F 0080 0081 0082  |{|}~....|
   7113 	00000098  0083 0084 0085 0086 - 0087 0088 0089 008A  |........|
   7114 	000000A0  008B 008C 008D 008E - 008F 0090 0091 0092  |........|
   7115 	000000A8  0093 0094 0095 0096 - 0097 0098 0099 009A  |........|
   7116 	000000B0  009B 009C 009D 009E - 009F 00A0 00A1 00A2  |.....|
   7117 	000000B8  00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA  ||
   7118 	000000C0  00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2  ||
   7119 	000000C8  00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA  ||
   7120 	000000D0  00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2  ||
   7121 	000000D8  00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA  ||
   7122 	000000E0  00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2  ||
   7123 	000000E8  00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA  ||
   7124 	000000F0  00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2  ||
   7125 	000000F8  00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA  ||
   7126 	00000100  00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2  ||
   7127 	00000108  00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA  ||
   7128 	00000110  00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A  |..|
   7129 	00000118  EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80  |..|
   7130 	00000120  000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF  |..|
   7131 	00000128  EFBE EFEF EFBF EFBF - 000A 007A 000A       |.z.|
   7132 ---
   7133 name: integer-base-one-3Ar
   7134 description:
   7135 	some sample code for hexdumping; NUL and binary safe
   7136 stdin:
   7137 	{
   7138 		print 'Hello, World!\\\n'
   7139 		typeset -Uui16 i=0x100
   7140 		# change that to 0xFF once we can handle embedded
   7141 		# NUL characters in strings / here documents
   7142 		while (( i++ < 0x1FF )); do
   7143 			print -n "\x${i#16#1}"
   7144 		done
   7145 		print '\0z'
   7146 	} | {
   7147 		# integer-base-one-3Ar
   7148 		typeset -Uui16 -Z11 pos=0
   7149 		typeset -Uui16 -Z5 hv=2147483647
   7150 		dasc=
   7151 		if read -arN -1 line; then
   7152 			typeset -i1 line
   7153 			i=0
   7154 			while (( i < ${#line[*]} )); do
   7155 				hv=${line[i++]}
   7156 				if (( (pos & 15) == 0 )); then
   7157 					(( pos )) && print "$dasc|"
   7158 					print -n "${pos#16#}  "
   7159 					dasc=' |'
   7160 				fi
   7161 				print -n "${hv#16#} "
   7162 				if (( (hv < 32) || (hv > 126) )); then
   7163 					dasc=$dasc.
   7164 				else
   7165 					dasc=$dasc${line[i-1]#1#}
   7166 				fi
   7167 				(( (pos++ & 15) == 7 )) && print -n -- '- '
   7168 			done
   7169 		fi
   7170 		while (( pos & 15 )); do
   7171 			print -n '   '
   7172 			(( (pos++ & 15) == 7 )) && print -n -- '- '
   7173 		done
   7174 		(( hv == 2147483647 )) || print "$dasc|"
   7175 	}
   7176 expected-stdout:
   7177 	00000000  48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3  |Hello, World!\..|
   7178 	00000010  81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC  |................|
   7179 	00000020  81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E  |................|
   7180 	00000030  0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E  |................|
   7181 	00000040  1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E  |. !"#$%&'()*+,-.|
   7182 	00000050  2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E  |/0123456789:;<=>|
   7183 	00000060  3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E  |?@ABCDEFGHIJKLMN|
   7184 	00000070  4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E  |OPQRSTUVWXYZ[\]^|
   7185 	00000080  5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E  |_`abcdefghijklmn|
   7186 	00000090  6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E  |opqrstuvwxyz{|}~|
   7187 	000000A0  7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E  |................|
   7188 	000000B0  8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E  |................|
   7189 	000000C0  9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE  |................|
   7190 	000000D0  AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE  |................|
   7191 	000000E0  BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE  |................|
   7192 	000000F0  CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE  |................|
   7193 	00000100  DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE  |................|
   7194 	00000110  EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE  |................|
   7195 	00000120  FF 00 7A 0A             -                          |..z.|
   7196 ---
   7197 name: integer-base-one-3Wr
   7198 description:
   7199 	some sample code for hexdumping Unicode; NUL and binary safe
   7200 stdin:
   7201 	set -U
   7202 	{
   7203 		print 'Hello, World!\\\n'
   7204 		typeset -Uui16 i=0x100
   7205 		# change that to 0xFF once we can handle embedded
   7206 		# NUL characters in strings / here documents
   7207 		while (( i++ < 0x1FF )); do
   7208 			print -n "\u${i#16#1}"
   7209 		done
   7210 		print
   7211 		print \\xff		# invalid utf-8
   7212 		print \\xc2		# invalid 2-byte
   7213 		print \\xef\\xbf\\xc0	# invalid 3-byte
   7214 		print \\xc0\\x80	# non-minimalistic
   7215 		print \\xe0\\x80\\x80	# non-minimalistic
   7216 		print ''	# end of range
   7217 		print '\0z'		# embedded NUL
   7218 	} | {
   7219 		# integer-base-one-3Wr
   7220 		typeset -Uui16 -Z11 pos=0
   7221 		typeset -Uui16 -Z7 hv=2147483647
   7222 		dasc=
   7223 		if read -arN -1 line; then
   7224 			typeset -i1 line
   7225 			i=0
   7226 			while (( i < ${#line[*]} )); do
   7227 				hv=${line[i++]}
   7228 				if (( (hv < 32) || \
   7229 				    ((hv > 126) && (hv < 160)) )); then
   7230 					dch=.
   7231 				elif (( (hv & 0xFF80) == 0xEF80 )); then
   7232 					dch=
   7233 				else
   7234 					dch=${line[i-1]#1#}
   7235 				fi
   7236 				if (( (pos & 7) == 7 )); then
   7237 					dasc=$dasc$dch
   7238 					dch=
   7239 				elif (( (pos & 7) == 0 )); then
   7240 					(( pos )) && print "$dasc|"
   7241 					print -n "${pos#16#}  "
   7242 					dasc=' |'
   7243 				fi
   7244 				print -n "${hv#16#} "
   7245 				(( (pos++ & 7) == 3 )) && \
   7246 				    print -n -- '- '
   7247 				dasc=$dasc$dch
   7248 			done
   7249 		fi
   7250 		while (( pos & 7 )); do
   7251 			print -n '     '
   7252 			(( (pos++ & 7) == 3 )) && print -n -- '- '
   7253 		done
   7254 		(( hv == 2147483647 )) || print "$dasc|"
   7255 	}
   7256 expected-stdout:
   7257 	00000000  0048 0065 006C 006C - 006F 002C 0020 0057  |Hello, W|
   7258 	00000008  006F 0072 006C 0064 - 0021 005C 000A 3053  |orld!\.|
   7259 	00000010  3093 306B 3061 306F - FF01 000A 0001 0002  |...|
   7260 	00000018  0003 0004 0005 0006 - 0007 0008 0009 000A  |........|
   7261 	00000020  000B 000C 000D 000E - 000F 0010 0011 0012  |........|
   7262 	00000028  0013 0014 0015 0016 - 0017 0018 0019 001A  |........|
   7263 	00000030  001B 001C 001D 001E - 001F 0020 0021 0022  |..... !"|
   7264 	00000038  0023 0024 0025 0026 - 0027 0028 0029 002A  |#$%&'()*|
   7265 	00000040  002B 002C 002D 002E - 002F 0030 0031 0032  |+,-./012|
   7266 	00000048  0033 0034 0035 0036 - 0037 0038 0039 003A  |3456789:|
   7267 	00000050  003B 003C 003D 003E - 003F 0040 0041 0042  |;<=>?@AB|
   7268 	00000058  0043 0044 0045 0046 - 0047 0048 0049 004A  |CDEFGHIJ|
   7269 	00000060  004B 004C 004D 004E - 004F 0050 0051 0052  |KLMNOPQR|
   7270 	00000068  0053 0054 0055 0056 - 0057 0058 0059 005A  |STUVWXYZ|
   7271 	00000070  005B 005C 005D 005E - 005F 0060 0061 0062  |[\]^_`ab|
   7272 	00000078  0063 0064 0065 0066 - 0067 0068 0069 006A  |cdefghij|
   7273 	00000080  006B 006C 006D 006E - 006F 0070 0071 0072  |klmnopqr|
   7274 	00000088  0073 0074 0075 0076 - 0077 0078 0079 007A  |stuvwxyz|
   7275 	00000090  007B 007C 007D 007E - 007F 0080 0081 0082  |{|}~....|
   7276 	00000098  0083 0084 0085 0086 - 0087 0088 0089 008A  |........|
   7277 	000000A0  008B 008C 008D 008E - 008F 0090 0091 0092  |........|
   7278 	000000A8  0093 0094 0095 0096 - 0097 0098 0099 009A  |........|
   7279 	000000B0  009B 009C 009D 009E - 009F 00A0 00A1 00A2  |.....|
   7280 	000000B8  00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA  ||
   7281 	000000C0  00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2  ||
   7282 	000000C8  00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA  ||
   7283 	000000D0  00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2  ||
   7284 	000000D8  00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA  ||
   7285 	000000E0  00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2  ||
   7286 	000000E8  00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA  ||
   7287 	000000F0  00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2  ||
   7288 	000000F8  00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA  ||
   7289 	00000100  00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2  ||
   7290 	00000108  00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA  ||
   7291 	00000110  00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A  |..|
   7292 	00000118  EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80  |..|
   7293 	00000120  000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF  |..|
   7294 	00000128  EFBE EFEF EFBF EFBF - 000A 0000 007A 000A  |..z.|
   7295 ---
   7296 name: integer-base-one-4
   7297 description:
   7298 	Check if ksh93-style base-one integers work
   7299 category: !smksh
   7300 stdin:
   7301 	set -U
   7302 	echo 1 $(('a'))
   7303 	(echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
   7304 	echo 3 $((''))
   7305 	x="'a'"
   7306 	echo "4 <$x>"
   7307 	echo 5 $(($x))
   7308 	echo 6 $((x))
   7309 expected-stdout:
   7310 	1 97
   7311 	2p 'aa': multi-character character constant
   7312 	3 8230
   7313 	4 <'a'>
   7314 	5 97
   7315 	6 97
   7316 ---
   7317 name: integer-base-one-5A
   7318 description:
   7319 	Check to see that were NUL and Unicode safe
   7320 stdin:
   7321 	set +U
   7322 	print 'a\0b\xfdz' >x
   7323 	read -a y <x
   7324 	set -U
   7325 	typeset -Uui16 y
   7326 	print ${y[*]} .
   7327 expected-stdout:
   7328 	16#61 16#0 16#62 16#FD 16#7A .
   7329 ---
   7330 name: integer-base-one-5W
   7331 description:
   7332 	Check to see that were NUL and Unicode safe
   7333 stdin:
   7334 	set -U
   7335 	print 'a\0bc' >x
   7336 	read -a y <x
   7337 	set +U
   7338 	typeset -Uui16 y
   7339 	print ${y[*]} .
   7340 expected-stdout:
   7341 	16#61 16#0 16#62 16#20AC 16#63 .
   7342 ---
   7343 name: ulimit-1
   7344 description:
   7345 	Check if we can use a specific syntax idiom for ulimit
   7346 stdin:
   7347 	if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
   7348 		#echo expected to fail on this OS
   7349 		echo okay
   7350 	else
   7351 		ulimit -dS $x && echo okay
   7352 	fi
   7353 expected-stdout:
   7354 	okay
   7355 ---
   7356 name: bashiop-1
   7357 description:
   7358 	Check if GNU bash-like I/O redirection works
   7359 	Part 1: this is also supported by GNU bash
   7360 stdin:
   7361 	exec 3>&1
   7362 	function threeout {
   7363 		echo ras
   7364 		echo dwa >&2
   7365 		echo tri >&3
   7366 	}
   7367 	threeout &>foo
   7368 	echo ===
   7369 	cat foo
   7370 expected-stdout:
   7371 	tri
   7372 	===
   7373 	ras
   7374 	dwa
   7375 ---
   7376 name: bashiop-2a
   7377 description:
   7378 	Check if GNU bash-like I/O redirection works
   7379 	Part 2: this is *not* supported by GNU bash
   7380 stdin:
   7381 	exec 3>&1
   7382 	function threeout {
   7383 		echo ras
   7384 		echo dwa >&2
   7385 		echo tri >&3
   7386 	}
   7387 	threeout 3&>foo
   7388 	echo ===
   7389 	cat foo
   7390 expected-stdout:
   7391 	ras
   7392 	===
   7393 	dwa
   7394 	tri
   7395 ---
   7396 name: bashiop-2b
   7397 description:
   7398 	Check if GNU bash-like I/O redirection works
   7399 	Part 2: this is *not* supported by GNU bash
   7400 stdin:
   7401 	exec 3>&1
   7402 	function threeout {
   7403 		echo ras
   7404 		echo dwa >&2
   7405 		echo tri >&3
   7406 	}
   7407 	threeout 3>foo &>&3
   7408 	echo ===
   7409 	cat foo
   7410 expected-stdout:
   7411 	===
   7412 	ras
   7413 	dwa
   7414 	tri
   7415 ---
   7416 name: bashiop-2c
   7417 description:
   7418 	Check if GNU bash-like I/O redirection works
   7419 	Part 2: this is supported by GNU bash 4 only
   7420 stdin:
   7421 	echo mir >foo
   7422 	set -o noclobber
   7423 	exec 3>&1
   7424 	function threeout {
   7425 		echo ras
   7426 		echo dwa >&2
   7427 		echo tri >&3
   7428 	}
   7429 	threeout &>>foo
   7430 	echo ===
   7431 	cat foo
   7432 expected-stdout:
   7433 	tri
   7434 	===
   7435 	mir
   7436 	ras
   7437 	dwa
   7438 ---
   7439 name: bashiop-3a
   7440 description:
   7441 	Check if GNU bash-like I/O redirection fails correctly
   7442 	Part 1: this is also supported by GNU bash
   7443 stdin:
   7444 	echo mir >foo
   7445 	set -o noclobber
   7446 	exec 3>&1
   7447 	function threeout {
   7448 		echo ras
   7449 		echo dwa >&2
   7450 		echo tri >&3
   7451 	}
   7452 	threeout &>foo
   7453 	echo ===
   7454 	cat foo
   7455 expected-stdout:
   7456 	===
   7457 	mir
   7458 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
   7459 ---
   7460 name: bashiop-3b
   7461 description:
   7462 	Check if GNU bash-like I/O redirection fails correctly
   7463 	Part 2: this is *not* supported by GNU bash
   7464 stdin:
   7465 	echo mir >foo
   7466 	set -o noclobber
   7467 	exec 3>&1
   7468 	function threeout {
   7469 		echo ras
   7470 		echo dwa >&2
   7471 		echo tri >&3
   7472 	}
   7473 	threeout &>|foo
   7474 	echo ===
   7475 	cat foo
   7476 expected-stdout:
   7477 	tri
   7478 	===
   7479 	ras
   7480 	dwa
   7481 ---
   7482 name: bashiop-4
   7483 description:
   7484 	Check if GNU bash-like I/O redirection works
   7485 	Part 4: this is also supported by GNU bash,
   7486 	but failed in some mksh versions
   7487 stdin:
   7488 	exec 3>&1
   7489 	function threeout {
   7490 		echo ras
   7491 		echo dwa >&2
   7492 		echo tri >&3
   7493 	}
   7494 	function blubb {
   7495 		[[ -e bar ]] && threeout "$bf" &>foo
   7496 	}
   7497 	blubb
   7498 	echo -n >bar
   7499 	blubb
   7500 	echo ===
   7501 	cat foo
   7502 expected-stdout:
   7503 	tri
   7504 	===
   7505 	ras
   7506 	dwa
   7507 ---
   7508 name: mkshiop-1
   7509 description:
   7510 	Check for support of more than 9 file descriptors
   7511 category: !convfds
   7512 stdin:
   7513 	read -u10 foo 10<<< bar
   7514 	echo x$foo
   7515 expected-stdout:
   7516 	xbar
   7517 ---
   7518 name: mkshiop-2
   7519 description:
   7520 	Check for support of more than 9 file descriptors
   7521 category: !convfds
   7522 stdin:
   7523 	exec 12>foo
   7524 	print -u12 bar
   7525 	echo baz >&12
   7526 	cat foo
   7527 expected-stdout:
   7528 	bar
   7529 	baz
   7530 ---
   7531 name: oksh-shcrash
   7532 description:
   7533 	src/regress/bin/ksh/shcrash.sh,v 1.1
   7534 stdin:
   7535 	deplibs="-lz -lpng /usr/local/lib/libjpeg.la -ltiff -lm -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -ltiff -ljpeg -lz -lpng -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk_pixbuf.la -lz -lpng /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile -L/usr/local/lib /usr/local/lib/libesd.la -lm -lz -L/usr/local/lib /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib -L/usr/local/lib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lpng /usr/local/lib/libungif.la -lz /usr/local/lib/libjpeg.la -ltiff -L/usr/local/lib -L/usr/X11R6/lib /usr/local/lib/libgdk_imlib.la -lm -L/usr/local/lib /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lICE -lSM -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lm -lz -lpng -lungif -lz -ljpeg -ltiff -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd -L/usr/local/lib /usr/local/lib/libgnomeui.la -lz -lz /usr/local/lib/libxml.la -lz -lz -lz /usr/local/lib/libxml.la -lm -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la /usr/local/lib/libgmodule.la -lintl -lglib -lgmodule /usr/local/lib/libgdk.la /usr/local/lib/libgtk.la -L/usr/X11R6/lib -L/usr/local/lib /usr/local/lib/libglade.la -lz -lz -lz /usr/local/lib/libxml.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile /usr/local/lib/libesd.la -lm -lz /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -lglib -lgmodule /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -lglib -lgmodule /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lz /usr/local/lib/libgdk_imlib.la /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lz -lungif -lz -ljpeg -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd /usr/local/lib/libgnomeui.la -L/usr/X11R6/lib -L/usr/local/lib /usr/local/lib/libglade-gnome.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile -L/usr/local/lib /usr/local/lib/libesd.la -lm -lz -L/usr/local/lib /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib -L/usr/local/lib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lpng /usr/local/lib/libungif.la -lz /usr/local/lib/libjpeg.la -ltiff -L/usr/local/lib -L/usr/X11R6/lib /usr/local/lib/libgdk_imlib.la -lm -L/usr/local/lib /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lICE -lSM -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lm -lz -lpng -lungif -lz -ljpeg -ltiff -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd -L/usr/local/lib /usr/local/lib/libgnomeui.la -L/usr/X11R6/lib -L/usr/local/lib"
   7536 	specialdeplibs="-lgnomeui -lart_lgpl -lgdk_imlib -ltiff -ljpeg -lungif -lpng -lz -lSM -lICE -lgtk -lgdk -lgmodule -lintl -lXext -lX11 -lgnome -lgnomesupport -lesd -laudiofile -lm -lglib"
   7537 	for deplib in $deplibs; do
   7538 		case $deplib in
   7539 		-L*)
   7540 			new_libs="$deplib $new_libs"
   7541 			;;
   7542 		*)
   7543 			case " $specialdeplibs " in
   7544 			*" $deplib "*)
   7545 				new_libs="$deplib $new_libs";;
   7546 			esac
   7547 			;;
   7548 		esac
   7549 	done
   7550 ---
   7551 name: oksh-varfunction-mod1
   7552 description:
   7553 	$OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $
   7554 	Calling
   7555 		FOO=bar f
   7556 	where f is a ksh style function, should not set FOO in the current
   7557 	env. If f is a Bourne style function, FOO should be set. Furthermore,
   7558 	the function should receive a correct value of FOO. However, differing
   7559 	from oksh, setting FOO in the function itself must change the value in
   7560 	setting FOO in the function itself should not change the value in
   7561 	global environment.
   7562 	Inspired by PR 2450.
   7563 stdin:
   7564 	function k {
   7565 		if [ x$FOO != xbar ]; then
   7566 			echo 1
   7567 			return 1
   7568 		fi
   7569 		x=$(env | grep FOO)
   7570 		if [ "x$x" != "xFOO=bar" ]; then
   7571 			echo 2
   7572 			return 1;
   7573 		fi
   7574 		FOO=foo
   7575 		return 0
   7576 	}
   7577 	b () {
   7578 		if [ x$FOO != xbar ]; then
   7579 			echo 3
   7580 			return 1
   7581 		fi
   7582 		x=$(env | grep FOO)
   7583 		if [ "x$x" != "xFOO=bar" ]; then
   7584 			echo 4
   7585 			return 1;
   7586 		fi
   7587 		FOO=foo
   7588 		return 0
   7589 	}
   7590 	FOO=bar k
   7591 	if [ $? != 0 ]; then
   7592 		exit 1
   7593 	fi
   7594 	if [ x$FOO != x ]; then
   7595 		exit 1
   7596 	fi
   7597 	FOO=bar b
   7598 	if [ $? != 0 ]; then
   7599 		exit 1
   7600 	fi
   7601 	if [ x$FOO != xfoo ]; then
   7602 		exit 1
   7603 	fi
   7604 	FOO=barbar
   7605 	FOO=bar k
   7606 	if [ $? != 0 ]; then
   7607 		exit 1
   7608 	fi
   7609 	if [ x$FOO != xbarbar ]; then
   7610 		exit 1
   7611 	fi
   7612 	FOO=bar b
   7613 	if [ $? != 0 ]; then
   7614 		exit 1
   7615 	fi
   7616 	if [ x$FOO != xfoo ]; then
   7617 		exit 1
   7618 	fi
   7619 ---
   7620 name: fd-cloexec-1
   7621 description:
   7622 	Verify that file descriptors > 2 are private for Korn shells
   7623 	AT&T ksh93 does this still, which means we must keep it as well
   7624 file-setup: file 644 "test.sh"
   7625 	echo >&3 Fowl
   7626 stdin:
   7627 	exec 3>&1
   7628 	"$__progname" test.sh
   7629 expected-exit: e != 0
   7630 expected-stderr-pattern:
   7631 	/bad file descriptor/
   7632 ---
   7633 name: fd-cloexec-2
   7634 description:
   7635 	Verify that file descriptors > 2 are not private for POSIX shells
   7636 	See Debian Bug #154540, Closes: #499139
   7637 file-setup: file 644 "test.sh"
   7638 	echo >&3 Fowl
   7639 stdin:
   7640 	test -n "$POSH_VERSION" || set -o sh
   7641 	exec 3>&1
   7642 	"$__progname" test.sh
   7643 expected-stdout:
   7644 	Fowl
   7645 ---
   7646 name: comsub-1a
   7647 description:
   7648 	COMSUB are now parsed recursively, so this works
   7649 	see also regression-6: matching parenthess bug
   7650 	Fails on: pdksh bash2 bash3 zsh
   7651 	Passes on: bash4 ksh93 mksh(20110313+)
   7652 stdin:
   7653 	echo $(case 1 in (1) echo yes;; (2) echo no;; esac)
   7654 	echo $(case 1 in 1) echo yes;; 2) echo no;; esac)
   7655 	TEST=1234; echo ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)}
   7656 	TEST=5678; echo ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)}
   7657 expected-stdout:
   7658 	yes
   7659 	yes
   7660 	234
   7661 	678
   7662 ---
   7663 name: comsub-1b
   7664 description:
   7665 	COMSUB are now parsed recursively, so this works
   7666 	Fails on GNU bash even, ksh93 passes
   7667 stdin:
   7668 	echo $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))
   7669 	echo $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))
   7670 	(( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo $a.
   7671 	(( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo $a.
   7672 expected-stdout:
   7673 	11
   7674 	21
   7675 	1.
   7676 	1.
   7677 ---
   7678 name: comsub-1c
   7679 description:
   7680 	COMSUB are now parsed recursively, so this works (ksh93, mksh)
   7681 	First test passes on bash4, second fails there
   7682 category: !smksh
   7683 stdin:
   7684 	a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo ${a[0]}.
   7685 	a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo ${a[0]}.
   7686 	a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo ${a[0]}.
   7687 	a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo ${a[0]}.
   7688 expected-stdout:
   7689 	1.
   7690 	1.
   7691 	11.
   7692 	21.
   7693 ---
   7694 name: comsub-2
   7695 description:
   7696 	RedHat BZ#496791  another case of missing recursion
   7697 	in parsing COMSUB expressions
   7698 	Fails on: pdksh bash2 bash3 bash4 zsh
   7699 	Passes on: ksh93 mksh(20110305+)
   7700 	 bash[34] seem to choke on comment ending with backslash-newline
   7701 stdin:
   7702 	# a comment with " ' \
   7703 	x=$(
   7704 	echo yes
   7705 	# a comment with " ' \
   7706 	)
   7707 	echo $x
   7708 expected-stdout:
   7709 	yes
   7710 ---
   7711 name: comsub-3
   7712 description:
   7713 	Extended test for COMSUB explaining why a recursive parser
   7714 	is a must (a non-recursive parser cannot pass all three of
   7715 	these test cases, especially the # is difficult)
   7716 stdin:
   7717 	echo $(typeset -i10 x=16#20; echo $x)
   7718 	echo $(typeset -Uui16 x=16#$(id -u)
   7719 	) .
   7720 	echo $(c=1; d=1
   7721 	typeset -Uui16 a=36#foo; c=2
   7722 	typeset -Uui16 b=36 #foo; d=2
   7723 	echo $a $b $c $d)
   7724 expected-stdout:
   7725 	32
   7726 	.
   7727 	16#4F68 16#24 2 1
   7728 ---
   7729 name: comsub-4
   7730 description:
   7731 	Check the tree dump functions for !MKSH_SMALL functionality
   7732 category: !smksh
   7733 stdin:
   7734 	x() { case $1 in a) a+=b ;;& *) c+=(d e) ;; esac; }
   7735 	typeset -f x
   7736 expected-stdout:
   7737 	x() {
   7738 		case $1 in
   7739 		(a)
   7740 			a+=b 
   7741 			;|
   7742 		(*)
   7743 			set -A c+ -- d e 
   7744 			;;
   7745 		esac 
   7746 	} 
   7747 ---
   7748 name: comsub-torture
   7749 description:
   7750 	Check the tree dump functions work correctly
   7751 stdin:
   7752 	if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
   7753 	while IFS= read -r line; do
   7754 		if [[ $line = '#1' ]]; then
   7755 			lastf=0
   7756 			continue
   7757 		elif [[ $line = EOFN* ]]; then
   7758 			fbody=$fbody$'\n'$line
   7759 			continue
   7760 		elif [[ $line != '#'* ]]; then
   7761 			fbody=$fbody$'\n\t'$line
   7762 			continue
   7763 		fi
   7764 		if (( lastf )); then
   7765 			x="inline_${nextf}() {"$fbody$'\n}\n'
   7766 			print -nr -- "$x"
   7767 			print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
   7768 			x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
   7769 			print -nr -- "$x"
   7770 			print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
   7771 			x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
   7772 			print -nr -- "$x"
   7773 			print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
   7774 		fi
   7775 		lastf=1
   7776 		fbody=
   7777 		nextf=${line#?}
   7778 	done <<'EOD'
   7779 	#1
   7780 	#TCOM
   7781 	vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4"
   7782 	#TPAREN_TPIPE_TLIST
   7783 	(echo $foo  |  tr -dc 0-9; echo)
   7784 	#TAND_TOR
   7785 	cmd  &&  echo ja  ||  echo nein
   7786 	#TSELECT
   7787 	select  file  in  *;  do  echo  "<$file>" ;  break ;  done
   7788 	#TFOR_TTIME
   7789 	for  i  in  {1,2,3}  ;  do  time  echo  $i ;  done
   7790 	#TCASE
   7791 	case  $foo  in  1)  echo eins;& 2) echo zwei  ;| *) echo kann net bis drei zhlen;;  esac
   7792 	#TIF_TBANG_TDBRACKET_TELIF
   7793 	if  !  [[  1  =  1  ]]  ;  then  echo eins;  elif [[ 1 = 2 ]]; then echo zwei  ;else echo drei; fi
   7794 	#TWHILE
   7795 	i=1; while (( i < 10 )); do echo $i; let ++i; done
   7796 	#TUNTIL
   7797 	i=10; until  (( !--i )) ; do echo $i; done
   7798 	#TCOPROC
   7799 	cat  *  |&  ls
   7800 	#TFUNCT_TBRACE_TASYNC
   7801 	function  korn  {  echo eins; echo zwei ;  }
   7802 	bourne  ()  {  logger *  &  }
   7803 	#IOREAD_IOCAT
   7804 	tr  x  u  0<foo  >>bar
   7805 	#IOWRITE_IOCLOB_IOHERE_noIOSKIP
   7806 	cat  >|bar  <<'EOFN'
   7807 	foo
   7808 	EOFN
   7809 	#IOWRITE_noIOCLOB_IOHERE_IOSKIP
   7810 	cat  1>bar  <<-EOFI
   7811 	foo
   7812 	EOFI
   7813 	#IORDWR_IODUP
   7814 	sh  1<>/dev/console  0<&1  2>&1
   7815 	#COMSUB_EXPRSUB
   7816 	echo $(true) $((1+ 2))
   7817 	#QCHAR_OQUOTE_CQUOTE
   7818 	echo fo\ob\"a\`r\'b\$az
   7819 	echo "fo\ob\"a\`r\'b\$az"
   7820 	echo 'fo\ob\"a\`r'\''b\$az'
   7821 	#OSUBST_CSUBST_OPAT_SPAT_CPAT
   7822 	[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
   7823 	#heredoc_closed
   7824 	x=$(cat <<EOFN
   7825 	note there must be no space between EOFN and )
   7826 	EOFN); echo $x
   7827 	#heredoc_space
   7828 	x=$(cat <<EOFN\ 
   7829 	note the space between EOFN and ) is actually part of the here document marker
   7830 	EOFN ); echo $x
   7831 	#patch_motd
   7832 	x=$(sysctl -n kern.version | sed 1q)
   7833 	[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
   7834 	    ed -s /etc/motd 2>&1 <<-EOF
   7835 		1,/^\$/d
   7836 		0a
   7837 			$x
   7838 	
   7839 		.
   7840 		wq
   7841 	EOF)" = @(?) ]] && rm -f /etc/motd
   7842 	if [[ ! -s /etc/motd ]]; then
   7843 		install -c -o root -g wheel -m 664 /dev/null /etc/motd
   7844 		print -- "$x\n" >/etc/motd
   7845 	fi
   7846 	#0
   7847 	EOD
   7848 expected-stdout:
   7849 	inline_TCOM() {
   7850 		vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4"
   7851 	}
   7852 	inline_TCOM() {
   7853 		vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" 
   7854 	} 
   7855 	function comsub_TCOM { x=$(
   7856 		vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4"
   7857 	); }
   7858 	function comsub_TCOM {
   7859 		x=$(vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" ) 
   7860 	} 
   7861 	function reread_TCOM { x=$((
   7862 		vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4"
   7863 	)|tr u x); }
   7864 	function reread_TCOM {
   7865 		x=$(( vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" ) | tr u x ) 
   7866 	} 
   7867 	inline_TPAREN_TPIPE_TLIST() {
   7868 		(echo $foo  |  tr -dc 0-9; echo)
   7869 	}
   7870 	inline_TPAREN_TPIPE_TLIST() {
   7871 		( echo $foo | tr -dc 0-9 
   7872 		  echo ) 
   7873 	} 
   7874 	function comsub_TPAREN_TPIPE_TLIST { x=$(
   7875 		(echo $foo  |  tr -dc 0-9; echo)
   7876 	); }
   7877 	function comsub_TPAREN_TPIPE_TLIST {
   7878 		x=$(( echo $foo | tr -dc 0-9 ; echo ) ) 
   7879 	} 
   7880 	function reread_TPAREN_TPIPE_TLIST { x=$((
   7881 		(echo $foo  |  tr -dc 0-9; echo)
   7882 	)|tr u x); }
   7883 	function reread_TPAREN_TPIPE_TLIST {
   7884 		x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x ) 
   7885 	} 
   7886 	inline_TAND_TOR() {
   7887 		cmd  &&  echo ja  ||  echo nein
   7888 	}
   7889 	inline_TAND_TOR() {
   7890 		cmd && echo ja || echo nein 
   7891 	} 
   7892 	function comsub_TAND_TOR { x=$(
   7893 		cmd  &&  echo ja  ||  echo nein
   7894 	); }
   7895 	function comsub_TAND_TOR {
   7896 		x=$(cmd && echo ja || echo nein ) 
   7897 	} 
   7898 	function reread_TAND_TOR { x=$((
   7899 		cmd  &&  echo ja  ||  echo nein
   7900 	)|tr u x); }
   7901 	function reread_TAND_TOR {
   7902 		x=$(( cmd && echo ja || echo nein ) | tr u x ) 
   7903 	} 
   7904 	inline_TSELECT() {
   7905 		select  file  in  *;  do  echo  "<$file>" ;  break ;  done
   7906 	}
   7907 	inline_TSELECT() {
   7908 		select file in * 
   7909 		do
   7910 			echo "<$file>" 
   7911 			break 
   7912 		done 
   7913 	} 
   7914 	function comsub_TSELECT { x=$(
   7915 		select  file  in  *;  do  echo  "<$file>" ;  break ;  done
   7916 	); }
   7917 	function comsub_TSELECT {
   7918 		x=$(select file in * ; do echo "<$file>" ; break ; done ) 
   7919 	} 
   7920 	function reread_TSELECT { x=$((
   7921 		select  file  in  *;  do  echo  "<$file>" ;  break ;  done
   7922 	)|tr u x); }
   7923 	function reread_TSELECT {
   7924 		x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x ) 
   7925 	} 
   7926 	inline_TFOR_TTIME() {
   7927 		for  i  in  {1,2,3}  ;  do  time  echo  $i ;  done
   7928 	}
   7929 	inline_TFOR_TTIME() {
   7930 		for i in {1,2,3} 
   7931 		do
   7932 			time echo $i 
   7933 		done 
   7934 	} 
   7935 	function comsub_TFOR_TTIME { x=$(
   7936 		for  i  in  {1,2,3}  ;  do  time  echo  $i ;  done
   7937 	); }
   7938 	function comsub_TFOR_TTIME {
   7939 		x=$(for i in {1,2,3} ; do time echo $i ; done ) 
   7940 	} 
   7941 	function reread_TFOR_TTIME { x=$((
   7942 		for  i  in  {1,2,3}  ;  do  time  echo  $i ;  done
   7943 	)|tr u x); }
   7944 	function reread_TFOR_TTIME {
   7945 		x=$(( for i in {1,2,3} ; do time echo $i ; done ) | tr u x ) 
   7946 	} 
   7947 	inline_TCASE() {
   7948 		case  $foo  in  1)  echo eins;& 2) echo zwei  ;| *) echo kann net bis drei zhlen;;  esac
   7949 	}
   7950 	inline_TCASE() {
   7951 		case $foo in
   7952 		(1)
   7953 			echo eins 
   7954 			;&
   7955 		(2)
   7956 			echo zwei 
   7957 			;|
   7958 		(*)
   7959 			echo kann net bis drei zhlen 
   7960 			;;
   7961 		esac 
   7962 	} 
   7963 	function comsub_TCASE { x=$(
   7964 		case  $foo  in  1)  echo eins;& 2) echo zwei  ;| *) echo kann net bis drei zhlen;;  esac
   7965 	); }
   7966 	function comsub_TCASE {
   7967 		x=$(case $foo in (1) echo eins  ;& (2) echo zwei  ;| (*) echo kann net bis drei zhlen  ;; esac ) 
   7968 	} 
   7969 	function reread_TCASE { x=$((
   7970 		case  $foo  in  1)  echo eins;& 2) echo zwei  ;| *) echo kann net bis drei zhlen;;  esac
   7971 	)|tr u x); }
   7972 	function reread_TCASE {
   7973 		x=$(( case $foo in (1) echo eins  ;& (2) echo zwei  ;| (*) echo kann net bis drei zhlen  ;; esac ) | tr u x ) 
   7974 	} 
   7975 	inline_TIF_TBANG_TDBRACKET_TELIF() {
   7976 		if  !  [[  1  =  1  ]]  ;  then  echo eins;  elif [[ 1 = 2 ]]; then echo zwei  ;else echo drei; fi
   7977 	}
   7978 	inline_TIF_TBANG_TDBRACKET_TELIF() {
   7979 		if ! [[ 1 = 1 ]] 
   7980 		then
   7981 			echo eins 
   7982 		elif [[ 1 = 2 ]] 
   7983 		then
   7984 			echo zwei 
   7985 		else
   7986 			echo drei 
   7987 		fi 
   7988 	} 
   7989 	function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
   7990 		if  !  [[  1  =  1  ]]  ;  then  echo eins;  elif [[ 1 = 2 ]]; then echo zwei  ;else echo drei; fi
   7991 	); }
   7992 	function comsub_TIF_TBANG_TDBRACKET_TELIF {
   7993 		x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) 
   7994 	} 
   7995 	function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
   7996 		if  !  [[  1  =  1  ]]  ;  then  echo eins;  elif [[ 1 = 2 ]]; then echo zwei  ;else echo drei; fi
   7997 	)|tr u x); }
   7998 	function reread_TIF_TBANG_TDBRACKET_TELIF {
   7999 		x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x ) 
   8000 	} 
   8001 	inline_TWHILE() {
   8002 		i=1; while (( i < 10 )); do echo $i; let ++i; done
   8003 	}
   8004 	inline_TWHILE() {
   8005 		i=1 
   8006 		while let " i < 10 " 
   8007 		do
   8008 			echo $i 
   8009 			let ++i 
   8010 		done 
   8011 	} 
   8012 	function comsub_TWHILE { x=$(
   8013 		i=1; while (( i < 10 )); do echo $i; let ++i; done
   8014 	); }
   8015 	function comsub_TWHILE {
   8016 		x=$(i=1 ; while let " i < 10 " ; do echo $i ; let ++i ; done ) 
   8017 	} 
   8018 	function reread_TWHILE { x=$((
   8019 		i=1; while (( i < 10 )); do echo $i; let ++i; done
   8020 	)|tr u x); }
   8021 	function reread_TWHILE {
   8022 		x=$(( i=1 ; while let " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x ) 
   8023 	} 
   8024 	inline_TUNTIL() {
   8025 		i=10; until  (( !--i )) ; do echo $i; done
   8026 	}
   8027 	inline_TUNTIL() {
   8028 		i=10 
   8029 		until let " !--i " 
   8030 		do
   8031 			echo $i 
   8032 		done 
   8033 	} 
   8034 	function comsub_TUNTIL { x=$(
   8035 		i=10; until  (( !--i )) ; do echo $i; done
   8036 	); }
   8037 	function comsub_TUNTIL {
   8038 		x=$(i=10 ; until let " !--i " ; do echo $i ; done ) 
   8039 	} 
   8040 	function reread_TUNTIL { x=$((
   8041 		i=10; until  (( !--i )) ; do echo $i; done
   8042 	)|tr u x); }
   8043 	function reread_TUNTIL {
   8044 		x=$(( i=10 ; until let " !--i " ; do echo $i ; done ) | tr u x ) 
   8045 	} 
   8046 	inline_TCOPROC() {
   8047 		cat  *  |&  ls
   8048 	}
   8049 	inline_TCOPROC() {
   8050 		cat * |& 
   8051 		ls 
   8052 	} 
   8053 	function comsub_TCOPROC { x=$(
   8054 		cat  *  |&  ls
   8055 	); }
   8056 	function comsub_TCOPROC {
   8057 		x=$(cat * |&  ls ) 
   8058 	} 
   8059 	function reread_TCOPROC { x=$((
   8060 		cat  *  |&  ls
   8061 	)|tr u x); }
   8062 	function reread_TCOPROC {
   8063 		x=$(( cat * |&  ls ) | tr u x ) 
   8064 	} 
   8065 	inline_TFUNCT_TBRACE_TASYNC() {
   8066 		function  korn  {  echo eins; echo zwei ;  }
   8067 		bourne  ()  {  logger *  &  }
   8068 	}
   8069 	inline_TFUNCT_TBRACE_TASYNC() {
   8070 		function korn {
   8071 			echo eins 
   8072 			echo zwei 
   8073 		} 
   8074 		bourne() {
   8075 			logger * & 
   8076 		} 
   8077 	} 
   8078 	function comsub_TFUNCT_TBRACE_TASYNC { x=$(
   8079 		function  korn  {  echo eins; echo zwei ;  }
   8080 		bourne  ()  {  logger *  &  }
   8081 	); }
   8082 	function comsub_TFUNCT_TBRACE_TASYNC {
   8083 		x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * &  } ) 
   8084 	} 
   8085 	function reread_TFUNCT_TBRACE_TASYNC { x=$((
   8086 		function  korn  {  echo eins; echo zwei ;  }
   8087 		bourne  ()  {  logger *  &  }
   8088 	)|tr u x); }
   8089 	function reread_TFUNCT_TBRACE_TASYNC {
   8090 		x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * &  } ) | tr u x ) 
   8091 	} 
   8092 	inline_IOREAD_IOCAT() {
   8093 		tr  x  u  0<foo  >>bar
   8094 	}
   8095 	inline_IOREAD_IOCAT() {
   8096 		tr x u <foo >>bar 
   8097 	} 
   8098 	function comsub_IOREAD_IOCAT { x=$(
   8099 		tr  x  u  0<foo  >>bar
   8100 	); }
   8101 	function comsub_IOREAD_IOCAT {
   8102 		x=$(tr x u <foo >>bar ) 
   8103 	} 
   8104 	function reread_IOREAD_IOCAT { x=$((
   8105 		tr  x  u  0<foo  >>bar
   8106 	)|tr u x); }
   8107 	function reread_IOREAD_IOCAT {
   8108 		x=$(( tr x u <foo >>bar ) | tr u x ) 
   8109 	} 
   8110 	inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
   8111 		cat  >|bar  <<'EOFN'
   8112 		foo
   8113 	EOFN
   8114 	}
   8115 	inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
   8116 		cat >|bar <<"EOFN" 
   8117 		foo
   8118 	EOFN
   8119 	
   8120 	} 
   8121 	function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
   8122 		cat  >|bar  <<'EOFN'
   8123 		foo
   8124 	EOFN
   8125 	); }
   8126 	function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
   8127 		x=$(cat >|bar <<"EOFN" 
   8128 		foo
   8129 	EOFN
   8130 	) 
   8131 	} 
   8132 	function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
   8133 		cat  >|bar  <<'EOFN'
   8134 		foo
   8135 	EOFN
   8136 	)|tr u x); }
   8137 	function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
   8138 		x=$(( cat >|bar <<"EOFN" 
   8139 		foo
   8140 	EOFN
   8141 	) | tr u x ) 
   8142 	} 
   8143 	inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
   8144 		cat  1>bar  <<-EOFI
   8145 		foo
   8146 		EOFI
   8147 	}
   8148 	inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
   8149 		cat >bar <<-EOFI 
   8150 	foo
   8151 	EOFI
   8152 	
   8153 	} 
   8154 	function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
   8155 		cat  1>bar  <<-EOFI
   8156 		foo
   8157 		EOFI
   8158 	); }
   8159 	function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
   8160 		x=$(cat >bar <<-EOFI 
   8161 	foo
   8162 	EOFI
   8163 	) 
   8164 	} 
   8165 	function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
   8166 		cat  1>bar  <<-EOFI
   8167 		foo
   8168 		EOFI
   8169 	)|tr u x); }
   8170 	function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
   8171 		x=$(( cat >bar <<-EOFI 
   8172 	foo
   8173 	EOFI
   8174 	) | tr u x ) 
   8175 	} 
   8176 	inline_IORDWR_IODUP() {
   8177 		sh  1<>/dev/console  0<&1  2>&1
   8178 	}
   8179 	inline_IORDWR_IODUP() {
   8180 		sh 1<>/dev/console <&1 2>&1 
   8181 	} 
   8182 	function comsub_IORDWR_IODUP { x=$(
   8183 		sh  1<>/dev/console  0<&1  2>&1
   8184 	); }
   8185 	function comsub_IORDWR_IODUP {
   8186 		x=$(sh 1<>/dev/console <&1 2>&1 ) 
   8187 	} 
   8188 	function reread_IORDWR_IODUP { x=$((
   8189 		sh  1<>/dev/console  0<&1  2>&1
   8190 	)|tr u x); }
   8191 	function reread_IORDWR_IODUP {
   8192 		x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x ) 
   8193 	} 
   8194 	inline_COMSUB_EXPRSUB() {
   8195 		echo $(true) $((1+ 2))
   8196 	}
   8197 	inline_COMSUB_EXPRSUB() {
   8198 		echo $(true ) $((1+ 2)) 
   8199 	} 
   8200 	function comsub_COMSUB_EXPRSUB { x=$(
   8201 		echo $(true) $((1+ 2))
   8202 	); }
   8203 	function comsub_COMSUB_EXPRSUB {
   8204 		x=$(echo $(true ) $((1+ 2)) ) 
   8205 	} 
   8206 	function reread_COMSUB_EXPRSUB { x=$((
   8207 		echo $(true) $((1+ 2))
   8208 	)|tr u x); }
   8209 	function reread_COMSUB_EXPRSUB {
   8210 		x=$(( echo $(true ) $((1+ 2)) ) | tr u x ) 
   8211 	} 
   8212 	inline_QCHAR_OQUOTE_CQUOTE() {
   8213 		echo fo\ob\"a\`r\'b\$az
   8214 		echo "fo\ob\"a\`r\'b\$az"
   8215 		echo 'fo\ob\"a\`r'\''b\$az'
   8216 	}
   8217 	inline_QCHAR_OQUOTE_CQUOTE() {
   8218 		echo fo\ob\"a\`r\'b\$az 
   8219 		echo "fo\ob\"a\`r\'b\$az" 
   8220 		echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" 
   8221 	} 
   8222 	function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
   8223 		echo fo\ob\"a\`r\'b\$az
   8224 		echo "fo\ob\"a\`r\'b\$az"
   8225 		echo 'fo\ob\"a\`r'\''b\$az'
   8226 	); }
   8227 	function comsub_QCHAR_OQUOTE_CQUOTE {
   8228 		x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) 
   8229 	} 
   8230 	function reread_QCHAR_OQUOTE_CQUOTE { x=$((
   8231 		echo fo\ob\"a\`r\'b\$az
   8232 		echo "fo\ob\"a\`r\'b\$az"
   8233 		echo 'fo\ob\"a\`r'\''b\$az'
   8234 	)|tr u x); }
   8235 	function reread_QCHAR_OQUOTE_CQUOTE {
   8236 		x=$(( echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) | tr u x ) 
   8237 	} 
   8238 	inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
   8239 		[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
   8240 	}
   8241 	inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
   8242 		[[ ${foo#bl\(u\)b} = @(bar|baz) ]] 
   8243 	} 
   8244 	function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
   8245 		[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
   8246 	); }
   8247 	function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
   8248 		x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) 
   8249 	} 
   8250 	function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
   8251 		[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
   8252 	)|tr u x); }
   8253 	function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
   8254 		x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x ) 
   8255 	} 
   8256 	inline_heredoc_closed() {
   8257 		x=$(cat <<EOFN
   8258 		note there must be no space between EOFN and )
   8259 	EOFN); echo $x
   8260 	}
   8261 	inline_heredoc_closed() {
   8262 		x=$(cat <<EOFN 
   8263 		note there must be no space between EOFN and )
   8264 	EOFN
   8265 	) 
   8266 		echo $x 
   8267 	} 
   8268 	function comsub_heredoc_closed { x=$(
   8269 		x=$(cat <<EOFN
   8270 		note there must be no space between EOFN and )
   8271 	EOFN); echo $x
   8272 	); }
   8273 	function comsub_heredoc_closed {
   8274 		x=$(x=$(cat <<EOFN 
   8275 		note there must be no space between EOFN and )
   8276 	EOFN
   8277 	) ; echo $x ) 
   8278 	} 
   8279 	function reread_heredoc_closed { x=$((
   8280 		x=$(cat <<EOFN
   8281 		note there must be no space between EOFN and )
   8282 	EOFN); echo $x
   8283 	)|tr u x); }
   8284 	function reread_heredoc_closed {
   8285 		x=$(( x=$(cat <<EOFN 
   8286 		note there must be no space between EOFN and )
   8287 	EOFN
   8288 	) ; echo $x ) | tr u x ) 
   8289 	} 
   8290 	inline_heredoc_space() {
   8291 		x=$(cat <<EOFN\ 
   8292 		note the space between EOFN and ) is actually part of the here document marker
   8293 	EOFN ); echo $x
   8294 	}
   8295 	inline_heredoc_space() {
   8296 		x=$(cat <<EOFN\  
   8297 		note the space between EOFN and ) is actually part of the here document marker
   8298 	EOFN 
   8299 	) 
   8300 		echo $x 
   8301 	} 
   8302 	function comsub_heredoc_space { x=$(
   8303 		x=$(cat <<EOFN\ 
   8304 		note the space between EOFN and ) is actually part of the here document marker
   8305 	EOFN ); echo $x
   8306 	); }
   8307 	function comsub_heredoc_space {
   8308 		x=$(x=$(cat <<EOFN\  
   8309 		note the space between EOFN and ) is actually part of the here document marker
   8310 	EOFN 
   8311 	) ; echo $x ) 
   8312 	} 
   8313 	function reread_heredoc_space { x=$((
   8314 		x=$(cat <<EOFN\ 
   8315 		note the space between EOFN and ) is actually part of the here document marker
   8316 	EOFN ); echo $x
   8317 	)|tr u x); }
   8318 	function reread_heredoc_space {
   8319 		x=$(( x=$(cat <<EOFN\  
   8320 		note the space between EOFN and ) is actually part of the here document marker
   8321 	EOFN 
   8322 	) ; echo $x ) | tr u x ) 
   8323 	} 
   8324 	inline_patch_motd() {
   8325 		x=$(sysctl -n kern.version | sed 1q)
   8326 		[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
   8327 		    ed -s /etc/motd 2>&1 <<-EOF
   8328 			1,/^\$/d
   8329 			0a
   8330 				$x
   8331 		
   8332 			.
   8333 			wq
   8334 		EOF)" = @(?) ]] && rm -f /etc/motd
   8335 		if [[ ! -s /etc/motd ]]; then
   8336 			install -c -o root -g wheel -m 664 /dev/null /etc/motd
   8337 			print -- "$x\n" >/etc/motd
   8338 		fi
   8339 	}
   8340 	inline_patch_motd() {
   8341 		x=$(sysctl -n kern.version | sed 1q ) 
   8342 		[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 
   8343 	1,/^\$/d
   8344 	0a
   8345 	$x
   8346 	
   8347 	.
   8348 	wq
   8349 	EOF
   8350 	)" = @(?) ]] && rm -f /etc/motd 
   8351 		if [[ ! -s /etc/motd ]] 
   8352 		then
   8353 			install -c -o root -g wheel -m 664 /dev/null /etc/motd 
   8354 			print -- "$x\n" >/etc/motd 
   8355 		fi 
   8356 	} 
   8357 	function comsub_patch_motd { x=$(
   8358 		x=$(sysctl -n kern.version | sed 1q)
   8359 		[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
   8360 		    ed -s /etc/motd 2>&1 <<-EOF
   8361 			1,/^\$/d
   8362 			0a
   8363 				$x
   8364 		
   8365 			.
   8366 			wq
   8367 		EOF)" = @(?) ]] && rm -f /etc/motd
   8368 		if [[ ! -s /etc/motd ]]; then
   8369 			install -c -o root -g wheel -m 664 /dev/null /etc/motd
   8370 			print -- "$x\n" >/etc/motd
   8371 		fi
   8372 	); }
   8373 	function comsub_patch_motd {
   8374 		x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 
   8375 	1,/^\$/d
   8376 	0a
   8377 	$x
   8378 	
   8379 	.
   8380 	wq
   8381 	EOF
   8382 	)" = @(?) ]] && rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then install -c -o root -g wheel -m 664 /dev/null /etc/motd ; print -- "$x\n" >/etc/motd ; fi ) 
   8383 	} 
   8384 	function reread_patch_motd { x=$((
   8385 		x=$(sysctl -n kern.version | sed 1q)
   8386 		[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
   8387 		    ed -s /etc/motd 2>&1 <<-EOF
   8388 			1,/^\$/d
   8389 			0a
   8390 				$x
   8391 		
   8392 			.
   8393 			wq
   8394 		EOF)" = @(?) ]] && rm -f /etc/motd
   8395 		if [[ ! -s /etc/motd ]]; then
   8396 			install -c -o root -g wheel -m 664 /dev/null /etc/motd
   8397 			print -- "$x\n" >/etc/motd
   8398 		fi
   8399 	)|tr u x); }
   8400 	function reread_patch_motd {
   8401 		x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 
   8402 	1,/^\$/d
   8403 	0a
   8404 	$x
   8405 	
   8406 	.
   8407 	wq
   8408 	EOF
   8409 	)" = @(?) ]] && rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then install -c -o root -g wheel -m 664 /dev/null /etc/motd ; print -- "$x\n" >/etc/motd ; fi ) | tr u x ) 
   8410 	} 
   8411 ---
   8412 name: test-stnze-1
   8413 description:
   8414 	Check that the short form [ $x ] works
   8415 stdin:
   8416 	i=0
   8417 	[ -n $x ]
   8418 	rv=$?; echo $((++i)) $rv
   8419 	[ $x ]
   8420 	rv=$?; echo $((++i)) $rv
   8421 	[ -n "$x" ]
   8422 	rv=$?; echo $((++i)) $rv
   8423 	[ "$x" ]
   8424 	rv=$?; echo $((++i)) $rv
   8425 	x=0
   8426 	[ -n $x ]
   8427 	rv=$?; echo $((++i)) $rv
   8428 	[ $x ]
   8429 	rv=$?; echo $((++i)) $rv
   8430 	[ -n "$x" ]
   8431 	rv=$?; echo $((++i)) $rv
   8432 	[ "$x" ]
   8433 	rv=$?; echo $((++i)) $rv
   8434 	x='1 -a 1 = 2'
   8435 	[ -n $x ]
   8436 	rv=$?; echo $((++i)) $rv
   8437 	[ $x ]
   8438 	rv=$?; echo $((++i)) $rv
   8439 	[ -n "$x" ]
   8440 	rv=$?; echo $((++i)) $rv
   8441 	[ "$x" ]
   8442 	rv=$?; echo $((++i)) $rv
   8443 expected-stdout:
   8444 	1 0
   8445 	2 1
   8446 	3 1
   8447 	4 1
   8448 	5 0
   8449 	6 0
   8450 	7 0
   8451 	8 0
   8452 	9 1
   8453 	10 1
   8454 	11 0
   8455 	12 0
   8456 ---
   8457 name: test-stnze-2
   8458 description:
   8459 	Check that the short form [[ $x ]] works (ksh93 extension)
   8460 stdin:
   8461 	i=0
   8462 	[[ -n $x ]]
   8463 	rv=$?; echo $((++i)) $rv
   8464 	[[ $x ]]
   8465 	rv=$?; echo $((++i)) $rv
   8466 	[[ -n "$x" ]]
   8467 	rv=$?; echo $((++i)) $rv
   8468 	[[ "$x" ]]
   8469 	rv=$?; echo $((++i)) $rv
   8470 	x=0
   8471 	[[ -n $x ]]
   8472 	rv=$?; echo $((++i)) $rv
   8473 	[[ $x ]]
   8474 	rv=$?; echo $((++i)) $rv
   8475 	[[ -n "$x" ]]
   8476 	rv=$?; echo $((++i)) $rv
   8477 	[[ "$x" ]]
   8478 	rv=$?; echo $((++i)) $rv
   8479 	x='1 -a 1 = 2'
   8480 	[[ -n $x ]]
   8481 	rv=$?; echo $((++i)) $rv
   8482 	[[ $x ]]
   8483 	rv=$?; echo $((++i)) $rv
   8484 	[[ -n "$x" ]]
   8485 	rv=$?; echo $((++i)) $rv
   8486 	[[ "$x" ]]
   8487 	rv=$?; echo $((++i)) $rv
   8488 expected-stdout:
   8489 	1 1
   8490 	2 1
   8491 	3 1
   8492 	4 1
   8493 	5 0
   8494 	6 0
   8495 	7 0
   8496 	8 0
   8497 	9 0
   8498 	10 0
   8499 	11 0
   8500 	12 0
   8501 ---
   8502 name: event-subst-1a
   8503 description:
   8504 	Check that '!' substitution in interactive mode works
   8505 category: !smksh
   8506 file-setup: file 755 "falsetto"
   8507 	#! /bin/sh
   8508 	echo molto bene
   8509 	exit 42
   8510 file-setup: file 755 "!false"
   8511 	#! /bin/sh
   8512 	echo si
   8513 need-ctty: yes
   8514 arguments: !-i!
   8515 stdin:
   8516 	export PATH=.:$PATH
   8517 	falsetto
   8518 	echo yeap
   8519 	!false
   8520 expected-exit: 42
   8521 expected-stdout:
   8522 	molto bene
   8523 	yeap
   8524 	molto bene
   8525 expected-stderr-pattern:
   8526 	/.*/
   8527 ---
   8528 name: event-subst-1b
   8529 description:
   8530 	Check that '!' substitution in interactive mode works
   8531 	even when a space separates it from the search command,
   8532 	which is not what GNU bash provides but required for the
   8533 	other regression tests below to check
   8534 category: !smksh
   8535 file-setup: file 755 "falsetto"
   8536 	#! /bin/sh
   8537 	echo molto bene
   8538 	exit 42
   8539 file-setup: file 755 "!"
   8540 	#! /bin/sh
   8541 	echo si
   8542 need-ctty: yes
   8543 arguments: !-i!
   8544 stdin:
   8545 	export PATH=.:$PATH
   8546 	falsetto
   8547 	echo yeap
   8548 	! false
   8549 expected-exit: 42
   8550 expected-stdout:
   8551 	molto bene
   8552 	yeap
   8553 	molto bene
   8554 expected-stderr-pattern:
   8555 	/.*/
   8556 ---
   8557 name: event-subst-2
   8558 description:
   8559 	Check that '!' substitution in interactive mode
   8560 	does not break things
   8561 category: !smksh
   8562 file-setup: file 755 "falsetto"
   8563 	#! /bin/sh
   8564 	echo molto bene
   8565 	exit 42
   8566 file-setup: file 755 "!"
   8567 	#! /bin/sh
   8568 	echo si
   8569 need-ctty: yes
   8570 arguments: !-i!
   8571 env-setup: !ENV=./Env!
   8572 file-setup: file 644 "Env"
   8573 	PS1=X
   8574 stdin:
   8575 	export PATH=.:$PATH
   8576 	falsetto
   8577 	echo yeap
   8578 	!false
   8579 	echo meow
   8580 	! false
   8581 	echo = $?
   8582 	if
   8583 	! false; then echo foo; else echo bar; fi
   8584 expected-stdout:
   8585 	molto bene
   8586 	yeap
   8587 	molto bene
   8588 	meow
   8589 	molto bene
   8590 	= 42
   8591 	foo
   8592 expected-stderr-pattern:
   8593 	/.*/
   8594 ---
   8595 name: event-subst-3
   8596 description:
   8597 	Check that '!' substitution in noninteractive mode is ignored
   8598 category: !smksh
   8599 file-setup: file 755 "falsetto"
   8600 	#! /bin/sh
   8601 	echo molto bene
   8602 	exit 42
   8603 file-setup: file 755 "!false"
   8604 	#! /bin/sh
   8605 	echo si
   8606 stdin:
   8607 	export PATH=.:$PATH
   8608 	falsetto
   8609 	echo yeap
   8610 	!false
   8611 	echo meow
   8612 	! false
   8613 	echo = $?
   8614 	if
   8615 	! false; then echo foo; else echo bar; fi
   8616 expected-stdout:
   8617 	molto bene
   8618 	yeap
   8619 	si
   8620 	meow
   8621 	= 0
   8622 	foo
   8623 ---
   8624 name: nounset-1
   8625 description:
   8626 	Check that "set -u" matches (future) SUSv4 requirement
   8627 stdin:
   8628 	(set -u
   8629 	try() {
   8630 		local v
   8631 		eval v=\$$1
   8632 		if [[ -n $v ]]; then
   8633 			echo $1=nz
   8634 		else
   8635 			echo $1=zf
   8636 		fi
   8637 	}
   8638 	x=y
   8639 	(echo $x)
   8640 	echo =1
   8641 	(echo $y)
   8642 	echo =2
   8643 	(try x)
   8644 	echo =3
   8645 	(try y)
   8646 	echo =4
   8647 	(try 0)
   8648 	echo =5
   8649 	(try 2)
   8650 	echo =6
   8651 	(try)
   8652 	echo =7
   8653 	(echo at=$@)
   8654 	echo =8
   8655 	(echo asterisk=$*)
   8656 	echo =9
   8657 	(echo $?)
   8658 	echo =10
   8659 	(echo $!)
   8660 	echo =11
   8661 	(echo $-)
   8662 	echo =12
   8663 	#(echo $_)
   8664 	#echo =13
   8665 	(echo $#)
   8666 	echo =14
   8667 	(mypid=$$; try mypid)
   8668 	echo =15
   8669 	) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
   8670 expected-stdout:
   8671 	y
   8672 	=1
   8673 	y: parameter not set
   8674 	=2
   8675 	x=nz
   8676 	=3
   8677 	y: parameter not set
   8678 	=4
   8679 	0=nz
   8680 	=5
   8681 	2: parameter not set
   8682 	=6
   8683 	1: parameter not set
   8684 	=7
   8685 	at=
   8686 	=8
   8687 	asterisk=
   8688 	=9
   8689 	0
   8690 	=10
   8691 	!: parameter not set
   8692 	=11
   8693 	ush
   8694 	=12
   8695 	0
   8696 	=14
   8697 	mypid=nz
   8698 	=15
   8699 ---
   8700 name: nameref-1
   8701 description:
   8702 	Testsuite for nameref (bound variables)
   8703 stdin:
   8704 	bar=global
   8705 	typeset -n ir2=bar
   8706 	typeset -n ind=ir2
   8707 	echo !ind: ${!ind}
   8708 	echo ind: $ind
   8709 	echo !ir2: ${!ir2}
   8710 	echo ir2: $ir2
   8711 	typeset +n ind
   8712 	echo !ind: ${!ind}
   8713 	echo ind: $ind
   8714 	typeset -n ir2=ind
   8715 	echo !ir2: ${!ir2}
   8716 	echo ir2: $ir2
   8717 	set|grep ^ir2|sed 's/^/s1: /'
   8718 	typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
   8719 	set -A blub -- e1 e2 e3
   8720 	typeset -n ind=blub
   8721 	typeset -n ir2=blub[2]
   8722 	echo !ind[1]: ${!ind[1]}
   8723 	echo !ir2: $!ir2
   8724 	echo ind[1]: ${ind[1]}
   8725 	echo ir2: $ir2
   8726 expected-stdout:
   8727 	!ind: bar
   8728 	ind: global
   8729 	!ir2: bar
   8730 	ir2: global
   8731 	!ind: ind
   8732 	ind: ir2
   8733 	!ir2: ind
   8734 	ir2: ir2
   8735 	s1: ir2=ind
   8736 	s2: typeset -n ir2
   8737 	!ind[1]: 1
   8738 	!ir2: ir2
   8739 	ind[1]: e2
   8740 	ir2: e3
   8741 ---
   8742 name: nameref-2da
   8743 description:
   8744 	Testsuite for nameref (bound variables)
   8745 	Functions, argument given directly, after local
   8746 stdin:
   8747 	function foo {
   8748 		typeset bar=lokal baz=auch
   8749 		typeset -n v=bar
   8750 		echo entering
   8751 		echo !v: ${!v}
   8752 		echo !bar: ${!bar}
   8753 		echo !baz: ${!baz}
   8754 		echo bar: $bar
   8755 		echo v: $v
   8756 		v=123
   8757 		echo bar: $bar
   8758 		echo v: $v
   8759 		echo exiting
   8760 	}
   8761 	bar=global
   8762 	echo bar: $bar
   8763 	foo bar
   8764 	echo bar: $bar
   8765 expected-stdout:
   8766 	bar: global
   8767 	entering
   8768 	!v: bar
   8769 	!bar: bar
   8770 	!baz: baz
   8771 	bar: lokal
   8772 	v: lokal
   8773 	bar: 123
   8774 	v: 123
   8775 	exiting
   8776 	bar: global
   8777 ---
   8778 name: nameref-3
   8779 description:
   8780 	Advanced testsuite for bound variables (ksh93 fails this)
   8781 stdin:
   8782 	typeset -n foo=bar[i]
   8783 	set -A bar -- b c a
   8784 	for i in 0 1 2 3; do
   8785 		print $i $foo .
   8786 	done
   8787 expected-stdout:
   8788 	0 b .
   8789 	1 c .
   8790 	2 a .
   8791 	3 .
   8792 ---
   8793 name: nameref-4
   8794 description:
   8795 	Ensure we don't run in an infinite loop
   8796 time-limit: 3
   8797 stdin:
   8798 	baz() {
   8799 		typeset -n foo=foo
   8800 		foo[0]=bar
   8801 	}
   8802 	set -A foo bad
   8803 	echo sind $foo .
   8804 	baz
   8805 	echo blah $foo .
   8806 expected-stdout:
   8807 	sind bad .
   8808 	blah bar .
   8809 ---
   8810 name: better-parens-1a
   8811 description:
   8812 	Check support for (()) and $(()) vs () and $()
   8813 stdin:
   8814 	if ( (echo fubar)|tr u x); then
   8815 		echo ja
   8816 	else
   8817 		echo nein
   8818 	fi
   8819 expected-stdout:
   8820 	fxbar
   8821 	ja
   8822 ---
   8823 name: better-parens-1b
   8824 description:
   8825 	Check support for (()) and $(()) vs () and $()
   8826 stdin:
   8827 	echo $( (echo fubar)|tr u x) $?
   8828 expected-stdout:
   8829 	fxbar 0
   8830 ---
   8831 name: better-parens-1c
   8832 description:
   8833 	Check support for (()) and $(()) vs () and $()
   8834 stdin:
   8835 	x=$( (echo fubar)|tr u x); echo $x $?
   8836 expected-stdout:
   8837 	fxbar 0
   8838 ---
   8839 name: better-parens-2a
   8840 description:
   8841 	Check support for (()) and $(()) vs () and $()
   8842 stdin:
   8843 	if ((echo fubar)|tr u x); then
   8844 		echo ja
   8845 	else
   8846 		echo nein
   8847 	fi
   8848 expected-stdout:
   8849 	fxbar
   8850 	ja
   8851 ---
   8852 name: better-parens-2b
   8853 description:
   8854 	Check support for (()) and $(()) vs () and $()
   8855 stdin:
   8856 	echo $((echo fubar)|tr u x) $?
   8857 expected-stdout:
   8858 	fxbar 0
   8859 ---
   8860 name: better-parens-2c
   8861 description:
   8862 	Check support for (()) and $(()) vs () and $()
   8863 stdin:
   8864 	x=$((echo fubar)|tr u x); echo $x $?
   8865 expected-stdout:
   8866 	fxbar 0
   8867 ---
   8868 name: better-parens-3a
   8869 description:
   8870 	Check support for (()) and $(()) vs () and $()
   8871 stdin:
   8872 	if ( (echo fubar)|(tr u x)); then
   8873 		echo ja
   8874 	else
   8875 		echo nein
   8876 	fi
   8877 expected-stdout:
   8878 	fxbar
   8879 	ja
   8880 ---
   8881 name: better-parens-3b
   8882 description:
   8883 	Check support for (()) and $(()) vs () and $()
   8884 stdin:
   8885 	echo $( (echo fubar)|(tr u x)) $?
   8886 expected-stdout:
   8887 	fxbar 0
   8888 ---
   8889 name: better-parens-3c
   8890 description:
   8891 	Check support for (()) and $(()) vs () and $()
   8892 stdin:
   8893 	x=$( (echo fubar)|(tr u x)); echo $x $?
   8894 expected-stdout:
   8895 	fxbar 0
   8896 ---
   8897 name: better-parens-4a
   8898 description:
   8899 	Check support for (()) and $(()) vs () and $()
   8900 stdin:
   8901 	if ((echo fubar)|(tr u x)); then
   8902 		echo ja
   8903 	else
   8904 		echo nein
   8905 	fi
   8906 expected-stdout:
   8907 	fxbar
   8908 	ja
   8909 ---
   8910 name: better-parens-4b
   8911 description:
   8912 	Check support for (()) and $(()) vs () and $()
   8913 stdin:
   8914 	echo $((echo fubar)|(tr u x)) $?
   8915 expected-stdout:
   8916 	fxbar 0
   8917 ---
   8918 name: better-parens-4c
   8919 description:
   8920 	Check support for (()) and $(()) vs () and $()
   8921 stdin:
   8922 	x=$((echo fubar)|(tr u x)); echo $x $?
   8923 expected-stdout:
   8924 	fxbar 0
   8925 ---
   8926 name: echo-test-1
   8927 description:
   8928 	Test what the echo builtin does (mksh)
   8929 stdin:
   8930 	echo -n 'foo\x40bar'
   8931 	echo -e '\tbaz'
   8932 expected-stdout:
   8933 	foo@bar	baz
   8934 ---
   8935 name: echo-test-2
   8936 description:
   8937 	Test what the echo builtin does (POSIX)
   8938 	Note: this follows Debian Policy 10.4 which mandates
   8939 	that -n shall be treated as an option, not XSI which
   8940 	mandates it shall be treated as string but escapes
   8941 	shall be expanded.
   8942 stdin:
   8943 	test -n "$POSH_VERSION" || set -o sh
   8944 	echo -n 'foo\x40bar'
   8945 	echo -e '\tbaz'
   8946 expected-stdout:
   8947 	foo\x40bar-e \tbaz
   8948 ---
   8949 name: utilities-getopts-1
   8950 description:
   8951 	getopts sets OPTIND correctly for unparsed option
   8952 stdin:
   8953 	set -- -a -a -x
   8954 	while getopts :a optc; do
   8955 	    echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
   8956 	done
   8957 	echo done
   8958 expected-stdout:
   8959 	OPTARG=, OPTIND=2, optc=a.
   8960 	OPTARG=, OPTIND=3, optc=a.
   8961 	OPTARG=x, OPTIND=4, optc=?.
   8962 	done
   8963 ---
   8964 name: utilities-getopts-2
   8965 description:
   8966 	Check OPTARG
   8967 stdin:
   8968 	set -- -a Mary -x
   8969 	while getopts a: optc; do
   8970 	    echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
   8971 	done
   8972 	echo done
   8973 expected-stdout:
   8974 	OPTARG=Mary, OPTIND=3, optc=a.
   8975 	OPTARG=, OPTIND=4, optc=?.
   8976 	done
   8977 expected-stderr-pattern: /.*-x.*option/
   8978 ---
   8979 name: wcswidth-1
   8980 description:
   8981 	Check the new wcswidth feature
   8982 stdin:
   8983 	s=
   8984 	set +U
   8985 	print octets: ${#s} .
   8986 	print 8-bit width: ${%s} .
   8987 	set -U
   8988 	print characters: ${#s} .
   8989 	print columns: ${%s} .
   8990 	s=
   8991 	set +U
   8992 	print octets: ${#s} .
   8993 	print 8-bit width: ${%s} .
   8994 	set -U
   8995 	print characters: ${#s} .
   8996 	print columns: ${%s} .
   8997 expected-stdout:
   8998 	octets: 3 .
   8999 	8-bit width: -1 .
   9000 	characters: 1 .
   9001 	columns: 2 .
   9002 	octets: 3 .
   9003 	8-bit width: 3 .
   9004 	characters: 1 .
   9005 	columns: 1 .
   9006 ---
   9007 name: wcswidth-2
   9008 description:
   9009 	Check some corner cases
   9010 stdin:
   9011 	print % $% .
   9012 	set -U
   9013 	x='a	b'
   9014 	print c ${%x} .
   9015 	set +U
   9016 	x='a	b'
   9017 	print d ${%x} .
   9018 expected-stdout:
   9019 	% $% .
   9020 	c -1 .
   9021 	d -1 .
   9022 ---
   9023 name: wcswidth-3
   9024 description:
   9025 	Check some corner cases
   9026 stdin:
   9027 	print ${%} .
   9028 expected-stderr-pattern:
   9029 	/bad substitution/
   9030 expected-exit: 1
   9031 ---
   9032 name: wcswidth-4a
   9033 description:
   9034 	Check some corner cases
   9035 stdin:
   9036 	print ${%*} .
   9037 expected-stderr-pattern:
   9038 	/bad substitution/
   9039 expected-exit: 1
   9040 ---
   9041 name: wcswidth-4b
   9042 description:
   9043 	Check some corner cases
   9044 stdin:
   9045 	print ${%@} .
   9046 expected-stderr-pattern:
   9047 	/bad substitution/
   9048 expected-exit: 1
   9049 ---
   9050 name: wcswidth-4c
   9051 description:
   9052 	Check some corner cases
   9053 stdin:
   9054 	:
   9055 	print ${%?} .
   9056 expected-stdout:
   9057 	1 .
   9058 ---
   9059 name: realpath-1
   9060 description:
   9061 	Check proper return values for realpath
   9062 category: os:mirbsd
   9063 stdin:
   9064 	wd=$(realpath .)
   9065 	mkdir dir
   9066 	:>file
   9067 	:>dir/file
   9068 	ln -s dir lndir
   9069 	ln -s file lnfile
   9070 	ln -s nix lnnix
   9071 	ln -s . lnself
   9072 	i=0
   9073 	chk() {
   9074 		typeset x y
   9075 		x=$(realpath "$wd/$1" 2>&1); y=$?
   9076 		print $((++i)) "?$1" =${x##*$wd/} !$y
   9077 	}
   9078 	chk dir
   9079 	chk dir/
   9080 	chk dir/file
   9081 	chk dir/nix
   9082 	chk file
   9083 	chk file/
   9084 	chk file/file
   9085 	chk file/nix
   9086 	chk nix
   9087 	chk nix/
   9088 	chk nix/file
   9089 	chk nix/nix
   9090 	chk lndir
   9091 	chk lndir/
   9092 	chk lndir/file
   9093 	chk lndir/nix
   9094 	chk lnfile
   9095 	chk lnfile/
   9096 	chk lnfile/file
   9097 	chk lnfile/nix
   9098 	chk lnnix
   9099 	chk lnnix/
   9100 	chk lnnix/file
   9101 	chk lnnix/nix
   9102 	chk lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself
   9103 	rm lnself
   9104 expected-stdout:
   9105 	1 ?dir =dir !0
   9106 	2 ?dir/ =dir !0
   9107 	3 ?dir/file =dir/file !0
   9108 	4 ?dir/nix =dir/nix !0
   9109 	5 ?file =file !0
   9110 	6 ?file/ =file/: Not a directory !20
   9111 	7 ?file/file =file/file: Not a directory !20
   9112 	8 ?file/nix =file/nix: Not a directory !20
   9113 	9 ?nix =nix !0
   9114 	10 ?nix/ =nix !0
   9115 	11 ?nix/file =nix/file: No such file or directory !2
   9116 	12 ?nix/nix =nix/nix: No such file or directory !2
   9117 	13 ?lndir =dir !0
   9118 	14 ?lndir/ =dir !0
   9119 	15 ?lndir/file =dir/file !0
   9120 	16 ?lndir/nix =dir/nix !0
   9121 	17 ?lnfile =file !0
   9122 	18 ?lnfile/ =lnfile/: Not a directory !20
   9123 	19 ?lnfile/file =lnfile/file: Not a directory !20
   9124 	20 ?lnfile/nix =lnfile/nix: Not a directory !20
   9125 	21 ?lnnix =nix !0
   9126 	22 ?lnnix/ =nix !0
   9127 	23 ?lnnix/file =lnnix/file: No such file or directory !2
   9128 	24 ?lnnix/nix =lnnix/nix: No such file or directory !2
   9129 	25 ?lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself =lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself: Too many levels of symbolic links !62
   9130 ---
   9131 name: realpath-2
   9132 description:
   9133 	Ensure that exactly two leading slashes are not collapsed
   9134 	POSIX guarantees this exception, e.g. for UNC paths on Cygwin
   9135 category: os:mirbsd
   9136 stdin:
   9137 	ln -s /bin t1
   9138 	ln -s //bin t2
   9139 	ln -s ///bin t3
   9140 	realpath /bin
   9141 	realpath //bin
   9142 	realpath ///bin
   9143 	realpath /usr/bin
   9144 	realpath /usr//bin
   9145 	realpath /usr///bin
   9146 	realpath t1
   9147 	realpath t2
   9148 	realpath t3
   9149 	rm -f t1 t2 t3
   9150 	cd //usr/bin
   9151 	pwd
   9152 	cd ../lib
   9153 	pwd
   9154 	realpath //usr/include/../bin
   9155 expected-stdout:
   9156 	/bin
   9157 	//bin
   9158 	/bin
   9159 	/usr/bin
   9160 	/usr/bin
   9161 	/usr/bin
   9162 	/bin
   9163 	//bin
   9164 	/bin
   9165 	//usr/bin
   9166 	//usr/lib
   9167 	//usr/bin
   9168 ---
   9169 name: crash-1
   9170 description:
   9171 	Crashed during March 2011, fixed on vernal equinx 
   9172 category: os:mirbsd,os:openbsd
   9173 stdin:
   9174 	export MALLOC_OPTIONS=FGJPRSX
   9175 	"$__progname" -c 'x=$(tr z r <<<baz); echo $x'
   9176 expected-stdout:
   9177 	bar
   9178 ---
   9179 name: debian-117-1
   9180 description:
   9181 	Check test - bug#465250
   9182 stdin:
   9183 	test \( ! -e \) ; echo $?
   9184 expected-stdout:
   9185 	1
   9186 ---
   9187 name: debian-117-2
   9188 description:
   9189 	Check test - bug#465250
   9190 stdin:
   9191 	test \(  -e \) ; echo $?
   9192 expected-stdout:
   9193 	0
   9194 ---
   9195 name: debian-117-3
   9196 description:
   9197 	Check test - bug#465250
   9198 stdin:
   9199 	test ! -e  ; echo $?
   9200 expected-stdout:
   9201 	1
   9202 ---
   9203 name: debian-117-4
   9204 description:
   9205 	Check test - bug#465250
   9206 stdin:
   9207 	test  -e  ; echo $?
   9208 expected-stdout:
   9209 	0
   9210 ---
   9211 name: case-zsh
   9212 description:
   9213 	Check that zsh case variants work
   9214 stdin:
   9215 	case 'b' in
   9216 	  a) echo a ;;
   9217 	  b) echo b ;;
   9218 	  c) echo c ;;
   9219 	  *) echo x ;;
   9220 	esac
   9221 	echo =
   9222 	case 'b' in
   9223 	  a) echo a ;&
   9224 	  b) echo b ;&
   9225 	  c) echo c ;&
   9226 	  *) echo x ;&
   9227 	esac
   9228 	echo =
   9229 	case 'b' in
   9230 	  a) echo a ;|
   9231 	  b) echo b ;|
   9232 	  c) echo c ;|
   9233 	  *) echo x ;|
   9234 	esac
   9235 expected-stdout:
   9236 	b
   9237 	=
   9238 	b
   9239 	c
   9240 	x
   9241 	=
   9242 	b
   9243 	x
   9244 ---
   9245