OSDN Git Service

Upgrade to mksh R55.
[android-x86/external-mksh.git] / src / check.t
index 98d260d..93c614f 100644 (file)
@@ -1,8 +1,8 @@
-# $MirOS: src/bin/mksh/check.t,v 1.721 2016/01/20 21:34:09 tg Exp $
+# $MirOS: src/bin/mksh/check.t,v 1.775 2017/04/12 17:38:41 tg Exp $
 # -*- mode: sh -*-
 #-
 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#            2011, 2012, 2013, 2014, 2015, 2016
+#            2011, 2012, 2013, 2014, 2015, 2016, 2017
 #      mirabilos <m@mirbsd.org>
 #
 # Provided that these terms and disclaimer and all copyright notices
 # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
 #
 # Integrated testsuites from:
-# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
+# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
 
 expected-stdout:
-       @(#)MIRBSD KSH R52 2016/01/20
+       @(#)MIRBSD KSH R55 2017/04/12
 description:
        Check version of shell.
 stdin:
        echo $KSH_VERSION
 name: KSH_VERSION
-category: shell:legacy-no
+category: !shell:legacy-yes,!shell:textmode-yes
 ---
 expected-stdout:
-       @(#)LEGACY KSH R52 2016/01/20
+       @(#)LEGACY KSH R55 2017/04/12
 description:
        Check version of legacy shell.
 stdin:
        echo $KSH_VERSION
 name: KSH_VERSION-legacy
-category: shell:legacy-yes
+category: !shell:legacy-no,!shell:textmode-yes
+---
+expected-stdout:
+       @(#)MIRBSD KSH R55 2017/04/12 +TEXTMODE
+description:
+       Check version of shell.
+stdin:
+       echo $KSH_VERSION
+name: KSH_VERSION-textmode
+category: !shell:legacy-yes,!shell:textmode-no
+---
+expected-stdout:
+       @(#)LEGACY KSH R55 2017/04/12 +TEXTMODE
+description:
+       Check version of legacy shell.
+stdin:
+       echo $KSH_VERSION
+name: KSH_VERSION-legacy-textmode
+category: !shell:legacy-no,!shell:textmode-no
 ---
 name: selftest-1
 description:
@@ -92,23 +110,6 @@ category: disabled
 stdin:
        set
 ---
-name: selftest-legacy
-description:
-       Check some things in the LEGACY KSH
-category: shell:legacy-yes
-stdin:
-       set +o emacs
-       set +o vi
-       [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 1=emacs
-       [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 1=vi
-       set -o emacs
-       set -o vi
-       [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 2=emacs
-       [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 2=vi
-expected-stdout:
-       2=emacs
-       2=vi
----
 name: selftest-direct-builtin-call
 description:
        Check that direct builtin calls work
@@ -119,6 +120,26 @@ stdin:
 expected-stdout:
        -c echo  foo
 ---
+name: selftest-pathsep-unix
+description:
+       Check that $PATHSEP is set correctly.
+category: !os:os2
+stdin:
+       PATHSEP=.; export PATHSEP
+       "$__progname" -c 'print -r -- $PATHSEP'
+expected-stdout:
+       :
+---
+name: selftest-pathsep-dospath
+description:
+       Check that $PATHSEP is set correctly.
+category: os:os2
+stdin:
+       PATHSEP=.; export PATHSEP
+       "$__progname" -c 'print -r -- $PATHSEP'
+expected-stdout:
+       ;
+---
 name: alias-1
 description:
        Check that recursion is detected/avoided in aliases.
@@ -199,7 +220,7 @@ description:
 stdin:
        alias X='case '
        alias Y=Z
-       X Y in 'Y') echo is y ;; Z) echo is z ; esac
+       X Y in 'Y') echo is y ;; Z) echo is z ;; esac
 expected-stdout:
        is z
 ---
@@ -261,14 +282,42 @@ name: alias-11
 description:
        Check that special argument handling still applies with escaped aliases
 stdin:
-       alias local='\typeset'
-       function foo {
-               local x=$1 y=z
+       alias local1='\typeset'
+       alias local2='\\builtin typeset'
+       function fooa {
+               local1 x=$1 y=z
                print -r -- "$x,$y"
        }
-       foo 'bar - baz'
+       function foob {
+               local2 x=$1 y=z
+               print -r -- "$x,$y"
+       }
+       x=1 y=2; fooa 'bar - baz'
+       x=1 y=2; foob 'bar - baz'
 expected-stdout:
        bar - baz,z
+       bar - baz,z
+---
+name: alias-12
+description:
+       Something weird from Martijn Dekker
+stdin:
+       alias echo=print
+       x() { echo a; (echo b); x=$(echo c); }
+       typeset -f x
+       alias OPEN='{' CLOSE='};'
+       { OPEN echo hi1; CLOSE }
+       var=`{ OPEN echo hi2; CLOSE }` && echo "$var"
+       var=$({ OPEN echo hi3; CLOSE }) && echo "$var"
+expected-stdout:
+       x() {
+               \print a 
+               ( \print b ) 
+               x=$(\print c ) 
+       } 
+       hi1
+       hi2
+       hi3
 ---
 name: arith-compound
 description:
@@ -340,6 +389,62 @@ expected-stdout:
        2
        0
 ---
+name: arith-lazy-5-arr-n
+description: Check lazy evaluation with side effects
+stdin:
+       a=0; echo "$((0&&b[a++],a))"
+expected-stdout:
+       0
+---
+name: arith-lazy-5-arr-p
+description: Check lazy evaluation with side effects
+stdin:
+       a=0; echo "$((0&&(b[a++]),a))"
+expected-stdout:
+       0
+---
+name: arith-lazy-5-str-n
+description: Check lazy evaluation with side effects
+stdin:
+       a=0 b=a++; ((0&&b)); echo $a
+expected-stdout:
+       0
+---
+name: arith-lazy-5-str-p
+description: Check lazy evaluation with side effects
+stdin:
+       a=0 b=a++; ((0&&(b))); echo $a
+expected-stdout:
+       0
+---
+name: arith-lazy-5-tern-l-n
+description: Check lazy evaluation with side effects
+stdin:
+       a=0; echo "$((0?b[a++]:999,a))"
+expected-stdout:
+       0
+---
+name: arith-lazy-5-tern-l-p
+description: Check lazy evaluation with side effects
+stdin:
+       a=0; echo "$((0?(b[a++]):999,a))"
+expected-stdout:
+       0
+---
+name: arith-lazy-5-tern-r-n
+description: Check lazy evaluation with side effects
+stdin:
+       a=0; echo "$((1?999:b[a++],a))"
+expected-stdout:
+       0
+---
+name: arith-lazy-5-tern-r-p
+description: Check lazy evaluation with side effects
+stdin:
+       a=0; echo "$((1?999:(b[a++]),a))"
+expected-stdout:
+       0
+---
 name: arith-ternary-prec-1
 description:
        Check precedence of ternary operator vs assignment
@@ -359,6 +464,18 @@ stdin:
 expected-stdout:
        20
 ---
+name: arith-prec-1
+description:
+       Prove arithmetic expressions with embedded parameter
+       substitutions cannot be parsed ahead of time
+stdin:
+       a='3 + 4'
+       print 1 $((2 * a)) .
+       print 2 $((2 * $a)) .
+expected-stdout:
+       1 14 .
+       2 10 .
+---
 name: arith-div-assoc-1
 description:
        Check associativity of division operator
@@ -884,6 +1001,8 @@ stdin:
            echo end-$i
        done
        echo end-3
+       for i in a b c; do echo $i; eval break; echo bad-$i; done
+       echo end-4
 expected-stdout:
        a
        end-1
@@ -896,6 +1015,8 @@ expected-stdout:
        c:x
        end-c
        end-3
+       a
+       end-4
 ---
 name: break-2
 description:
@@ -965,6 +1086,8 @@ stdin:
            echo end-$i
        done
        echo end-3
+       for i in a b c; do echo $i; eval continue; echo bad-$i ; done
+       echo end-4
 expected-stdout:
        a
        b
@@ -987,6 +1110,10 @@ expected-stdout:
        c:z
        end-c
        end-3
+       a
+       b
+       c
+       end-4
 ---
 name: continue-2
 description:
@@ -1311,6 +1438,7 @@ stdin:
        (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
        foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
        foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
+       (foo() { return 100; }; foo; echo 41 ${#+${#:+${#?}}\ \}\}\}}) 2>/dev/null || echo failed in 41
 expected-stdout:
        1 }z
        2 ''z}
@@ -1352,6 +1480,7 @@ expected-stdout:
        38 xay / x'a'y .
        39 x' / x' .
        40 < b c> .
+       41 3 }}}
 ---
 name: expand-unglob-dblq
 description:
@@ -1400,6 +1529,7 @@ stdin:
                (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
                    echo "$1 QSTN brac -> error"
        }
+       : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
        tl_norm 1 -
        tl_norm 2 ''
        tl_norm 3 x
@@ -1530,6 +1660,7 @@ stdin:
                (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
                    echo "$1 QSTN brac -> error"
        }
+       : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
        tl_norm 1 -
        tl_norm 2 ''
        tl_norm 3 x
@@ -1637,7 +1768,7 @@ expected-exit: 1
 ---
 name: expand-weird-1
 description:
-       Check corner case of trim expansion vs. $# vs. ${#var}
+       Check corner cases of trim expansion vs. $# vs. ${#var} vs. ${var?}
 stdin:
        set 1 2 3 4 5 6 7 8 9 10 11
        echo ${#}       # value of $#
@@ -1645,23 +1776,59 @@ stdin:
        echo ${##1}     # $# trimmed 1
        set 1 2 3 4 5 6 7 8 9 10 11 12
        echo ${##1}
+       (exit 0)
+       echo $? = ${#?} .
+       (exit 111)
+       echo $? = ${#?} .
 expected-stdout:
        11
        2
        1
        2
+       0 = 1 .
+       111 = 3 .
 ---
 name: expand-weird-2
 description:
-       Check corner case of ${var?} vs. ${#var}
-stdin:
-       (exit 0)
-       echo $? = ${#?} .
-       (exit 111)
-       echo $? = ${#?} .
-expected-stdout:
-       0 = 1 .
-       111 = 3 .
+       Check more substitution and extension corner cases
+stdin:
+       :& set -C; pid=$$; sub=$!; flg=$-; set -- i; exec 3>x.tmp
+       #echo "D: !=$! #=$# \$=$$ -=$- ?=$?"
+       echo >&3 3 = s^${!-word} , ${#-word} , p^${$-word} , f^${--word} , ${?-word} .
+       echo >&3 4 = ${!+word} , ${#+word} , ${$+word} , ${-+word} , ${?+word} .
+       echo >&3 5 = s^${!=word} , ${#=word} , p^${$=word} , f^${-=word} , ${?=word} .
+       echo >&3 6 = s^${!?word} , ${#?word} , p^${$?word} , f^${-?word} , ${??word} .
+       echo >&3 7 = sl^${#!} , ${##} , pl^${#$} , fl^${#-} , ${#?} .
+       echo >&3 8 = sw^${%!} , ${%#} , pw^${%$} , fw^${%-} , ${%?} .
+       echo >&3 9 = ${!!} , s^${!#} , ${!$} , s^${!-} , s^${!?} .
+       echo >&3 10 = s^${!#pattern} , ${##pattern} , p^${$#pattern} , f^${-#pattern} , ${?#pattern} .
+       echo >&3 11 = s^${!%pattern} , ${#%pattern} , p^${$%pattern} , f^${-%pattern} , ${?%pattern} .
+       echo >&3 12 = $# : ${##} , ${##1} .
+       set --
+       echo >&3 14 = $# : ${##} , ${##1} .
+       set -- 1 2 3 4 5
+       echo >&3 16 = $# : ${##} , ${##1} .
+       set -- 1 2 3 4 5 6 7 8 9 a b c d e
+       echo >&3 18 = $# : ${##} , ${##1} .
+       exec 3>&-
+       <x.tmp sed \
+           -e "s/ pl^${#pid} / PID /g" -e "s/ sl^${#sub} / SUB /g" -e "s/ fl^${#flg} / FLG /g" \
+           -e "s/ pw^${%pid} / PID /g" -e "s/ sw^${%sub} / SUB /g" -e "s/ fw^${%flg} / FLG /g" \
+           -e "s/ p^$pid / PID /g" -e "s/ s^$sub / SUB /g" -e "s/ f^$flg / FLG /g"
+expected-stdout:
+       3 = SUB , 1 , PID , FLG , 0 .
+       4 = word , word , word , word , word .
+       5 = SUB , 1 , PID , FLG , 0 .
+       6 = SUB , 1 , PID , FLG , 0 .
+       7 = SUB , 1 , PID , FLG , 1 .
+       8 = SUB , 1 , PID , FLG , 1 .
+       9 = ! , SUB , $ , SUB , SUB .
+       10 = SUB , 1 , PID , FLG , 0 .
+       11 = SUB , 1 , PID , FLG , 0 .
+       12 = 1 : 1 , .
+       14 = 0 : 1 , 0 .
+       16 = 5 : 1 , 5 .
+       18 = 14 : 2 , 4 .
 ---
 name: expand-weird-3
 description:
@@ -1687,6 +1854,50 @@ stdin:
 expected-stdout:
        <~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~>
 ---
+name: expand-bang-1
+description:
+       Check corner case of ${!?} with ! being var vs. op
+stdin:
+       echo ${!?}
+expected-exit: 1
+expected-stderr-pattern: /not set/
+---
+name: expand-bang-2
+description:
+       Check corner case of ${!var} vs. ${var op} with var=!
+stdin:
+       echo 1 $! .
+       echo 2 ${!#} .
+       echo 3 ${!#[0-9]} .
+       echo 4 ${!-foo} .
+       # get an at least three-digit bg pid
+       while :; do
+               :&
+               x=$!
+               if [[ $x != +([0-9]) ]]; then
+                       echo >&2 "cannot test, pid '$x' not numeric"
+                       echo >&2 report this with as many details as possible
+                       exit 1
+               fi
+               [[ $x = [0-9][0-9][0-9]* ]] && break
+       done
+       y=${x#?}
+       t=$!; [[ $t = $x ]]; echo 5 $? .
+       t=${!#}; [[ $t = $x ]]; echo 6 $? .
+       t=${!#[0-9]}; [[ $t = $y ]]; echo 7 $? .
+       t=${!-foo}; [[ $t = $x ]]; echo 8 $? .
+       t=${!?bar}; [[ $t = $x ]]; echo 9 $? .
+expected-stdout:
+       1 .
+       2 .
+       3 .
+       4 foo .
+       5 0 .
+       6 0 .
+       7 0 .
+       8 0 .
+       9 0 .
+---
 name: expand-number-1
 description:
        Check that positional arguments do not overflow
@@ -1695,6 +1906,41 @@ stdin:
 expected-stdout:
        1  .
 ---
+name: expand-slashes-1
+description:
+       Check that side effects in substring replacement are handled correctly
+stdin:
+       foo=n1n1n1n2n3
+       i=2
+       n=1
+       echo 1 ${foo//n$((n++))/[$((++i))]} .
+       echo 2 $n , $i .
+expected-stdout:
+       1 [3][3][3]n2n3 .
+       2 2 , 3 .
+---
+name: expand-slashes-2
+description:
+       Check that side effects in substring replacement are handled correctly
+stdin:
+       foo=n1n1n1n2n3
+       i=2
+       n=1
+       echo 1 ${foo@/n$((n++))/[$((++i))]} .
+       echo 2 $n , $i .
+expected-stdout:
+       1 [3]n1n1[4][5] .
+       2 5 , 5 .
+---
+name: expand-slashes-3
+description:
+       Check that we can access the replaced string
+stdin:
+       foo=n1n1n1n2n3
+       echo 1 ${foo@/n[12]/[$KSH_MATCH]} .
+expected-stdout:
+       1 [n1][n1][n1][n2]n3 .
+---
 name: eglob-bad-1
 description:
        Check that globbing isn't done when glob has syntax error
@@ -1858,7 +2104,7 @@ stdin:
        [[ -n $BASH_VERSION ]] && shopt -s extglob
        x=1222321_ab/cde_b/c_1221
        y=xyz
-       echo 1: ${x/2}
+       echo 1: ${x/2} . ${x/}
        echo 2: ${x//2}
        echo 3: ${x/+(2)}
        echo 4: ${x//+(2)}
@@ -1890,7 +2136,7 @@ stdin:
        echo 30: ${x//\\a/9}
        echo 31: ${x/2/$y}
 expected-stdout:
-       1: 122321_ab/cde_b/c_1221
+       1: 122321_ab/cde_b/c_1221 . 1222321_ab/cde_b/c_1221
        2: 131_ab/cde_b/c_11
        3: 1321_ab/cde_b/c_1221
        4: 131_ab/cde_b/c_11
@@ -2249,7 +2495,7 @@ expected-stdout:
        hi
        there
 ---
-name: heredoc-4
+name: heredoc-4a
 description:
        Check that an error occurs if the heredoc-delimiter is missing.
 stdin: !
@@ -2259,6 +2505,34 @@ stdin: !
 expected-exit: e > 0
 expected-stderr-pattern: /.*/
 ---
+name: heredoc-4an
+description:
+       Check that an error occurs if the heredoc-delimiter is missing.
+arguments: !-n!
+stdin: !
+       cat << EOF
+       hi
+       there
+expected-exit: e > 0
+expected-stderr-pattern: /.*/
+---
+name: heredoc-4b
+description:
+       Check that an error occurs if the heredoc is missing.
+stdin: !
+       cat << EOF
+expected-exit: e > 0
+expected-stderr-pattern: /.*/
+---
+name: heredoc-4bn
+description:
+       Check that an error occurs if the heredoc is missing.
+arguments: !-n!
+stdin: !
+       cat << EOF
+expected-exit: e > 0
+expected-stderr-pattern: /.*/
+---
 name: heredoc-5
 description:
        Check that backslash quotes a $, ` and \ and kills a \newline
@@ -2501,6 +2775,10 @@ stdin:
        eval "$fnd"
        foo
        print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
+       x=y
+       foo
+       typeset -f foo
+       print -r -- "| vc={$vc} vd={$vd} |"
        # check append
        v=<<-
                vapp1
@@ -2526,6 +2804,19 @@ expected-stdout:
        } vc={=c u \x40=
        } vd={=d $x \x40=
        } |
+       function foo {
+               vc=<<- 
+       =c $x \x40=
+       <<
+       
+               vd=<<-"" 
+       =d $x \x40=
+       
+       
+       } 
+       | vc={=c y \x40=
+       } vd={=d $x \x40=
+       } |
        | vapp1^vapp2^ |
 ---
 name: heredoc-12
@@ -2600,7 +2891,7 @@ stdin:
 expected-stdout:
        0
        bar() {
-               foo 4<<-a <<-b 5<<-c 
+               \foo 4<<-a <<-b 5<<-c 
        four
        a
        zero
@@ -2657,6 +2948,54 @@ stdin:
 expected-stdout:
        = these parens \( ) are a problem =
 ---
+name: heredoc-comsub-5
+description:
+       Check heredoc and COMSUB mixture in input
+stdin:
+       prefix() { sed -e "s/^/$1:/"; }
+       XXX() { echo x-en; }
+       YYY() { echo y-es; }
+       
+       prefix A <<XXX && echo "$(prefix B <<XXX
+       echo line 1
+       XXX
+       echo line 2)" && prefix C <<YYY
+       echo line 3
+       XXX
+       echo line 4)"
+       echo line 5
+       YYY
+       XXX
+expected-stdout:
+       A:echo line 3
+       B:echo line 1
+       line 2
+       C:echo line 4)"
+       C:echo line 5
+       x-en
+---
+name: heredoc-comsub-6
+description:
+       Check here documents and here strings can be used
+       without a specific command, like $(<…) (extension)
+stdin:
+       foo=bar
+       x=$(<<<EO${foo}F)
+       echo "3<$x>"
+               y=$(<<-EOF
+                       hi!
+       
+                       $foo) is not a problem
+       
+       
+               EOF)
+       echo "7<$y>"
+expected-stdout:
+       3<EObarF>
+       7<hi!
+       
+       bar) is not a problem>
+---
 name: heredoc-subshell-1
 description:
        Tests for here documents in subshells, taken from Austin ML
@@ -3119,6 +3458,37 @@ expected-stdout:
 expected-stderr-pattern:
        /(.*can't unlink HISTFILE.*\n)?X*$/
 ---
+name: history-multiline
+description:
+       Check correct multiline history, Debian #783978
+need-ctty: yes
+arguments: !-i!
+env-setup: !ENV=./Env!
+file-setup: file 644 "Env"
+       PS1=X
+       PS2=Y
+stdin:
+       for i in A B C
+       do
+          print $i
+          print $i
+       done
+       fc -l
+expected-stdout:
+       A
+       A
+       B
+       B
+       C
+       C
+       1       for i in A B C
+               do
+                  print $i
+                  print $i
+               done
+expected-stderr-pattern:
+       /^XYYYYXX$/
+---
 name: history-e-minus-1
 description:
        Check if more recent command is executed
@@ -4400,6 +4770,23 @@ expected-stdout:
        8 ok
        <9> <ab> <a b> .
 ---
+name: IFS-subst-10
+description:
+       Scalar context in ${var=$subst}
+stdin:
+       showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
+       set -- one "two three" four
+       unset -v var
+       save_IFS=$IFS
+       IFS=
+       set -- ${var=$*}
+       IFS=$save_IFS
+       echo "var=$var"
+       showargs "$@"
+expected-stdout:
+       var=onetwo threefour
+       <onetwo threefour> .
+---
 name: IFS-arith-1
 description:
        http://austingroupbugs.net/view.php?id=832
@@ -4637,7 +5024,7 @@ name: integer-base-check-flat
 description:
        Check behaviour does not match POSuX (except if set -o posix),
        because a not type-safe scripting language has *no* business
-       interpreting the string "010" as octal numer eight (dangerous).
+       interpreting the string "010" as octal number eight (dangerous).
 stdin:
        echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
        echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
@@ -4894,6 +5281,24 @@ expected-stdout:
        line <6>
 expected-exit: 1
 ---
+name: lineno-eval-alias
+description:
+       Check if LINENO is trapped in eval and aliases
+stdin:
+       ${ZSH_VERSION+false} || emulate sh; echo $LINENO
+       echo $LINENO
+       eval '  echo $LINENO
+               echo $LINENO
+               echo $LINENO'
+       echo $LINENO
+expected-stdout:
+       1
+       2
+       3
+       3
+       3
+       6
+---
 name: unknown-trap
 description:
        Ensure unknown traps are not a syntax error
@@ -6015,7 +6420,7 @@ name: regression-62
 description:
        Check if test -nt/-ot succeeds if second(first) file is missing.
 stdin:
-       touch a
+       :>a
        test a -nt b && echo nt OK || echo nt BAD
        test b -ot a && echo ot OK || echo ot BAD
 expected-stdout:
@@ -6162,6 +6567,106 @@ expected-stdout:
        ac_space=' '
        ac_newline=$'\n'
 ---
+name: regression-67
+description:
+       Check that we can both break and use source on the same line
+stdin:
+       for s in s; do break; done; print -s s
+---
+name: regression-68
+description:
+       Check that all common arithmetic operators work as expected
+stdin:
+       echo 1 $(( a = 5 )) .
+       echo 2 $(( ++a )) , $(( a++ )) , $(( a )) .
+       echo 3 $(( --a )) , $(( a-- )) , $(( a )) .
+       echo 4 $(( a == 5 )) , $(( a == 6 )) .
+       echo 5 $(( a != 5 )) , $(( a != 6 )) .
+       echo 6 $(( a *= 3 )) .
+       echo 7 $(( a /= 5 )) .
+       echo 8 $(( a %= 2 )) .
+       echo 9 $(( a += 9 )) .
+       echo 10 $(( a -= 4 )) .
+       echo 11 $(( a <<= 1 )) .
+       echo 12 $(( a >>= 1 )) .
+       echo 13 $(( a &= 4 )) .
+       echo 14 $(( a ^= a )) .
+       echo 15 $(( a |= 5 )) .
+       echo 16 $(( 5 << 1 )) .
+       echo 17 $(( 5 >> 1 )) .
+       echo 18 $(( 5 <= 6 )) , $(( 5 <= 5 )) , $(( 5 <= 4 )) .
+       echo 19 $(( 5 >= 6 )) , $(( 5 >= 5 )) , $(( 5 >= 4 )) .
+       echo 20 $(( 5 < 6 )) , $(( 5 < 5 )) , $(( 5 < 4 )) .
+       echo 21 $(( 5 > 6 )) , $(( 5 > 5 )) , $(( 5 > 4 )) .
+       echo 22 $(( 0 && 0 )) , $(( 0 && 1 )) , $(( 1 && 0 )) , $(( 1 && 1 )) .
+       echo 23 $(( 0 || 0 )) , $(( 0 || 1 )) , $(( 1 || 0 )) , $(( 1 || 1 )) .
+       echo 24 $(( 5 * 3 )) .
+       echo 25 $(( 7 / 2 )) .
+       echo 26 $(( 5 % 5 )) , $(( 5 % 4 )) , $(( 5 % 1 )) , $(( 5 % -1 )) , $(( 5 % -2 )) .
+       echo 27 $(( 5 + 2 )) , $(( 5 + 0 )) , $(( 5 + -2 )) .
+       echo 28 $(( 5 - 2 )) , $(( 5 - 0 )) , $(( 5 - -2 )) .
+       echo 29 $(( 6 & 4 )) , $(( 6 & 8 )) .
+       echo 30 $(( 4 ^ 2 )) , $(( 4 ^ 4 )) .
+       echo 31 $(( 4 | 2 )) , $(( 4 | 4 )) , $(( 4 | 0 )) .
+       echo 32 $(( 0 ? 1 : 2 )) , $(( 3 ? 4 : 5 )) .
+       echo 33 $(( 5 , 2 , 3 )) .
+       echo 34 $(( ~0 )) , $(( ~1 )) , $(( ~~1 )) , $(( ~~2 )) .
+       echo 35 $(( !0 )) , $(( !1 )) , $(( !!1 )) , $(( !!2 )) .
+       echo 36 $(( (5) )) .
+expected-stdout:
+       1 5 .
+       2 6 , 6 , 7 .
+       3 6 , 6 , 5 .
+       4 1 , 0 .
+       5 0 , 1 .
+       6 15 .
+       7 3 .
+       8 1 .
+       9 10 .
+       10 6 .
+       11 12 .
+       12 6 .
+       13 4 .
+       14 0 .
+       15 5 .
+       16 10 .
+       17 2 .
+       18 1 , 1 , 0 .
+       19 0 , 1 , 1 .
+       20 1 , 0 , 0 .
+       21 0 , 0 , 1 .
+       22 0 , 0 , 0 , 1 .
+       23 0 , 1 , 1 , 1 .
+       24 15 .
+       25 3 .
+       26 0 , 1 , 0 , 0 , 1 .
+       27 7 , 5 , 3 .
+       28 3 , 5 , 7 .
+       29 4 , 0 .
+       30 6 , 0 .
+       31 6 , 4 , 4 .
+       32 2 , 4 .
+       33 3 .
+       34 -1 , -2 , 1 , 2 .
+       35 1 , 0 , 1 , 1 .
+       36 5 .
+---
+name: regression-69
+description:
+       Check that all non-lksh arithmetic operators work as expected
+category: shell:legacy-no
+stdin:
+       a=5 b=0x80000005
+       echo 1 $(( a ^<= 1 )) , $(( b ^<= 1 )) .
+       echo 2 $(( a ^>= 2 )) , $(( b ^>= 2 )) .
+       echo 3 $(( 5 ^< 1 )) .
+       echo 4 $(( 5 ^> 1 )) .
+expected-stdout:
+       1 10 , 11 .
+       2 -2147483646 , -1073741822 .
+       3 10 .
+       4 -2147483646 .
+---
 name: readonly-0
 description:
        Ensure readonly is honoured for assignments and unset
@@ -6578,6 +7083,37 @@ stdin:
 expected-exit: 1
 expected-stderr-pattern: !/not set/
 ---
+name: xxx-param-subst-qmark-namespec
+description:
+       Check special names are output correctly
+stdin:
+       doit() {
+               "$__progname" -c "$@" >o1 2>o2
+               rv=$?
+               echo RETVAL: $rv
+               sed -e "s\ 1^${__progname%.exe}\.*e*x*e*: \ 1PROG: \ 1" -e 's/^/STDOUT: /g' <o1
+               sed -e "s\ 1^${__progname%.exe}\.*e*x*e*: \ 1PROG: \ 1" -e 's/^/STDERR: /g' <o2
+       }
+       doit 'echo ${1x}'
+       doit 'echo "${1x}"'
+       doit 'echo ${1?}'
+       doit 'echo ${19?}'
+       doit 'echo ${!:?}'
+       doit -u 'echo ${*:?}' foo ""
+expected-stdout:
+       RETVAL: 1
+       STDERR: PROG: ${1x}: bad substitution
+       RETVAL: 1
+       STDERR: PROG: ${1x}: bad substitution
+       RETVAL: 1
+       STDERR: PROG: 1: parameter null or not set
+       RETVAL: 1
+       STDERR: PROG: 19: parameter null or not set
+       RETVAL: 1
+       STDERR: PROG: !: parameter null or not set
+       RETVAL: 1
+       STDERR: foo: ${*:?}: bad substitution
+---
 name: xxx-param-_-1
 # fails due to weirdness of execv stuff
 category: !os:uwin-nt
@@ -6616,6 +7152,11 @@ description:
        Check tilde expansion works
 env-setup: !HOME=/sweet!
 stdin:
+       :>'c=a'
+       typeset c=[ab]
+       :>'d=a'
+       x=typeset; $x d=[ab]
+       echo "<$c>" "<$d>"
        wd=$PWD
        cd /
        plus=$(print -r -- ~+)
@@ -6625,10 +7166,106 @@ stdin:
        [[ $minus = "$wd" ]]; echo two $? .
        [[ $nix = /sweet ]]; echo nix $? .
 expected-stdout:
+       <[ab]> <a>
        one 0 .
        two 0 .
        nix 0 .
 ---
+name: tilde-expand-3
+description:
+       Check mostly Austin 351 stuff
+stdin:
+       showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
+       set "1 b=2" "3 d=4"
+       export a=$1 \c=$2
+       showargs 1 "$a" "$b" "$c" "$d"
+       unset a b c d
+       HOME=/tmp
+       export \a=~ b=~
+       command export c=~
+       builtin export d=~
+       \\builtin export e=~
+       showargs 2 "$a" "$b" "$c" "$d" "$e" ksh
+       unset a b c d e
+       set -o posix
+       export \a=~ b=~
+       command export c=~
+       builtin export d=~
+       \\builtin export e=~
+       showargs 3 "$a" "$b" "$c" "$d" "$e" posix
+       unset a b c d e
+       set +o posix
+       export a=$1
+       showargs 4 "$a" "$b" ksh
+       unset a b
+       showargs 5 a=$1 ksh
+       export \a=$1
+       showargs 6 "$a" "$b" ksh
+       unset a b
+       set -o posix
+       export a=$1
+       showargs 7 "$a" "$b" posix
+       unset a b
+       showargs 8 a=$1 posix
+       export \a=$1
+       showargs 9 "$a" "$b" posix
+       unset a b
+       set +o posix
+       command echo 10 ksh a=~
+       command command export a=~
+       showargs 11 "$a"
+       unset a
+       set -o posix
+       command echo 12 posix a=~
+       command command export a=~
+       showargs 13 "$a"
+       unset a
+       # unspecified whether /tmp or ~
+       var=export; command $var a=~
+       showargs 14 "$a"
+       echo 'echo "<$foo>"' >bar
+       "$__progname" bar
+       var=foo
+       export $var=1
+       "$__progname" bar
+       export $var=~
+       "$__progname" bar
+       # unspecified
+       command -- export a=~
+       showargs 18 "$a"
+       set -A bla
+       typeset bla[1]=~:~
+       global gbl=~ g2=$1
+       local lcl=~ l2=$1
+       readonly ro=~ r2=$1
+       showargs 19 "${bla[1]}" a=~ "$gbl" "$lcl" "$ro" "$g2" "$l2" "$r2"
+       set +o posix
+       echo "20 some arbitrary stuff "=~
+       set -o posix
+       echo "21 some arbitrary stuff "=~
+expected-stdout:
+       <1> <1 b=2> <> <3> <4> .
+       <2> </tmp> </tmp> </tmp> </tmp> </tmp> <ksh> .
+       <3> <~> </tmp> </tmp> <~> </tmp> <posix> .
+       <4> <1 b=2> <> <ksh> .
+       <5> <a=1> <b=2> <ksh> .
+       <6> <1> <2> <ksh> .
+       <7> <1 b=2> <> <posix> .
+       <8> <a=1> <b=2> <posix> .
+       <9> <1> <2> <posix> .
+       10 ksh a=/tmp
+       <11> </tmp> .
+       12 posix a=~
+       <13> </tmp> .
+       <14> <~> .
+       <>
+       <1>
+       <~>
+       <18> <~> .
+       <19> </tmp:/tmp> <a=~> </tmp> </tmp> </tmp> <1 b=2> <1 b=2> <1 b=2> .
+       20 some arbitrary stuff =/tmp
+       21 some arbitrary stuff =~
+---
 name: exit-err-1
 description:
        Check some "exit on error" conditions
@@ -6766,6 +7403,19 @@ stdin:
        db_go
        exit 0
 ---
+name: exit-err-9
+description:
+       "set -e" versus bang pipelines
+stdin:
+       set -e
+       ! false | false
+       echo 1 ok
+       ! false && false
+       echo 2 wrong
+expected-stdout:
+       1 ok
+expected-exit: 1
+---
 name: exit-enoent-1
 description:
        SUSv4 says that the shell should exit with 126/127 in some situations
@@ -6988,7 +7638,7 @@ expected-stdout:
        After error 2
        Exit trap
 expected-stderr-pattern:
-       /syntax error: 'newline' unexpected/
+       /syntax error: unexpected 'newline'/
 ---
 name: test-stlt-1
 description:
@@ -7098,6 +7748,58 @@ expected-stdout:
        2- 1 1 1 =
        3- 0 0 0 =
 ---
+name: test-varset-1
+description:
+       Test the test -v operator
+stdin:
+       [[ -v a ]]
+       rv=$?; echo $((++i)) $rv
+       a=
+       [[ -v a ]]
+       rv=$?; echo $((++i)) $rv
+       unset a
+       [[ -v a ]]
+       rv=$?; echo $((++i)) $rv
+       a=x
+       [[ -v a ]]
+       rv=$?; echo $((++i)) $rv
+       nameref b=a
+       [[ -v b ]]
+       rv=$?; echo $((++i)) $rv
+       unset a
+       [[ -v b ]]
+       rv=$?; echo $((++i)) $rv
+       x[1]=y
+       [[ -v x ]]
+       rv=$?; echo $((++i)) $rv
+       [[ -v x[0] ]]
+       rv=$?; echo $((++i)) $rv
+       [[ -v x[1] ]]
+       rv=$?; echo $((++i)) $rv
+       [[ -v x[2] ]]
+       rv=$?; echo $((++i)) $rv
+expected-stdout:
+       1 1
+       2 0
+       3 1
+       4 0
+       5 0
+       6 1
+       7 1
+       8 1
+       9 0
+       10 1
+---
+name: test-varset-2
+description:
+       test -v works only on scalars
+stdin:
+       [[ -v x[*] ]]
+       echo ok
+expected-exit: e != 0
+expected-stderr-pattern:
+       /unexpected '\*'/
+---
 name: test-stnze-1
 description:
        Check that the short form [ $x ] works
@@ -7448,11 +8150,11 @@ expected-stderr-pattern:
 ---
 name: typeset-1
 description:
-       Check that global does what typeset is supposed to do
+       Check that typeset -g works correctly
 stdin:
        set -A arrfoo 65
        foo() {
-               global -Uui16 arrfoo[*]
+               typeset -g -Uui16 arrfoo[*]
        }
        echo before ${arrfoo[0]} .
        foo
@@ -7462,7 +8164,7 @@ stdin:
                echo inside before ${arrbar[0]} .
                arrbar[0]=97
                echo inside changed ${arrbar[0]} .
-               global -Uui16 arrbar[*]
+               typeset -g -Uui16 arrbar[*]
                echo inside typeset ${arrbar[0]} .
                arrbar[0]=48
                echo inside changed ${arrbar[0]} .
@@ -7480,6 +8182,24 @@ expected-stdout:
        inside changed 16#30 .
        after 16#30 .
 ---
+name: typeset-2
+description:
+       Check that typeset -p on arrays works correctly
+stdin:
+       set -A x -- a b c
+       echo =
+       typeset -p x
+       echo =
+       typeset -p x[1]
+expected-stdout:
+       =
+       set -A x
+       typeset x[0]=a
+       typeset x[1]=b
+       typeset x[2]=c
+       =
+       typeset x[1]=b
+---
 name: typeset-padding-1
 description:
        Check if left/right justification works as per TFM
@@ -7626,7 +8346,7 @@ description:
        -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
         try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
 need-pass: no
-category: !os:hpux,!os:msys
+category: !os:hpux,!os:msys,!os:os2
 need-ctty: yes
 arguments: !-i!
 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
@@ -7690,6 +8410,27 @@ expected-stdout:
        2 off
        3 done
 ---
+name: utf8bug-1
+description:
+       Ensure trailing combining characters are not lost
+stdin:
+       set -U
+       a=a
+       b=$'\u0301'
+       x=$a$b
+       print -r -- "<e$x>"
+       x=$a
+       x+=$b
+       print -r -- "<e$x>"
+       b=$'\u0301'b
+       x=$a
+       x+=$b
+       print -r -- "<e$x>"
+expected-stdout:
+       <eá>
+       <eá>
+       <eáb>
+---
 name: aliases-1
 description:
        Check if built-in shell aliases are okay
@@ -7697,17 +8438,17 @@ stdin:
        alias
        typeset -f
 expected-stdout:
-       autoload='\typeset -fu'
-       functions='\typeset -f'
-       hash='\builtin alias -t'
-       history='\builtin fc -l'
-       integer='\typeset -i'
-       local='\typeset'
-       login='\exec login'
-       nameref='\typeset -n'
+       autoload='\\builtin typeset -fu'
+       functions='\\builtin typeset -f'
+       hash='\\builtin alias -t'
+       history='\\builtin fc -l'
+       integer='\\builtin typeset -i'
+       local='\\builtin typeset'
+       login='\\builtin exec login'
+       nameref='\\builtin typeset -n'
        nohup='nohup '
-       r='\builtin fc -e -'
-       type='\builtin whence -v'
+       r='\\builtin fc -e -'
+       type='\\builtin whence -v'
 ---
 name: aliases-2b
 description:
@@ -7717,17 +8458,17 @@ stdin:
        alias
        typeset -f
 expected-stdout:
-       autoload='\typeset -fu'
-       functions='\typeset -f'
-       hash='\builtin alias -t'
-       history='\builtin fc -l'
-       integer='\typeset -i'
-       local='\typeset'
-       login='\exec login'
-       nameref='\typeset -n'
+       autoload='\\builtin typeset -fu'
+       functions='\\builtin typeset -f'
+       hash='\\builtin alias -t'
+       history='\\builtin fc -l'
+       integer='\\builtin typeset -i'
+       local='\\builtin typeset'
+       login='\\builtin exec login'
+       nameref='\\builtin typeset -n'
        nohup='nohup '
-       r='\builtin fc -e -'
-       type='\builtin whence -v'
+       r='\\builtin fc -e -'
+       type='\\builtin whence -v'
 ---
 name: aliases-3b
 description:
@@ -7737,17 +8478,17 @@ stdin:
        ./sh -c 'alias; typeset -f'
        rm -f sh
 expected-stdout:
-       autoload='\typeset -fu'
-       functions='\typeset -f'
-       hash='\builtin alias -t'
-       history='\builtin fc -l'
-       integer='\typeset -i'
-       local='\typeset'
-       login='\exec login'
-       nameref='\typeset -n'
+       autoload='\\builtin typeset -fu'
+       functions='\\builtin typeset -f'
+       hash='\\builtin alias -t'
+       history='\\builtin fc -l'
+       integer='\\builtin typeset -i'
+       local='\\builtin typeset'
+       login='\\builtin exec login'
+       nameref='\\builtin typeset -n'
        nohup='nohup '
-       r='\builtin fc -e -'
-       type='\builtin whence -v'
+       r='\\builtin fc -e -'
+       type='\\builtin whence -v'
 ---
 name: aliases-cmdline
 description:
@@ -7804,8 +8545,8 @@ stdin:
        :|| local() { :; }
        alias local
 expected-stdout:
-       local='\typeset'
-       local='\typeset'
+       local='\\builtin typeset'
+       local='\\builtin typeset'
 ---
 name: arrays-1
 description:
@@ -8215,21 +8956,21 @@ expected-stdout:
 name: arrassign-fnc-global
 description:
        Check locality of array access inside a function
-       with the mksh-specific global keyword
+       with the bash4/mksh/yash/zsh typeset -g keyword
 stdin:
        function fn {
-               global x
+               typeset -g x
                x+=(f)
                echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
        }
        function rfn {
                set -A y
-               global y
+               typeset -g y
                y+=(f)
                echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
        }
        function fnr {
-               global z
+               typeset -g z
                set -A z
                z+=(f)
                echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
@@ -8367,21 +9108,21 @@ expected-stdout:
 name: strassign-fnc-global
 description:
        Check locality of string access inside a function
-       with the mksh-specific global keyword
+       with the bash4/mksh/yash/zsh typeset -g keyword
 stdin:
        function fn {
-               global x
+               typeset -g x
                x+=f
                echo ".fn:$x:"
        }
        function rfn {
                y=
-               global y
+               typeset -g y
                y+=f
                echo ".rfn:$y:"
        }
        function fnr {
-               global z
+               typeset -g z
                z=
                z+=f
                echo ".fnr:$z:"
@@ -8728,17 +9469,45 @@ name: print-funny-chars
 description:
        Check print builtin's capability to output designated characters
 stdin:
-       print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
-       print '<\x00>'
-       print '<\x01>'
-       print '<\u0000>'
-       print '<\u0001>'
+       {
+               print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
+               print '<\x00>'
+               print '<\x01>'
+               print '<\u0000>'
+               print '<\u0001>'
+       } | {
+               # integer-base-one-3Ar
+               typeset -Uui16 -Z11 pos=0
+               typeset -Uui16 -Z5 hv=2147483647
+               dasc=
+               if read -arN -1 line; then
+                       typeset -i1 line
+                       i=0
+                       while (( i < ${#line[*]} )); do
+                               hv=${line[i++]}
+                               if (( (pos & 15) == 0 )); then
+                                       (( pos )) && print -r -- "$dasc|"
+                                       print -n "${pos#16#}  "
+                                       dasc=' |'
+                               fi
+                               print -n "${hv#16#} "
+                               if (( (hv < 32) || (hv > 126) )); then
+                                       dasc=$dasc.
+                               else
+                                       dasc=$dasc${line[i-1]#1#}
+                               fi
+                               (( (pos++ & 15) == 7 )) && print -n -- '- '
+                       done
+               fi
+               while (( pos & 15 )); do
+                       print -n '   '
+                       (( (pos++ & 15) == 7 )) && print -n -- '- '
+               done
+               (( hv == 2147483647 )) || print -r -- "$dasc|"
+       }
 expected-stdout:
-       <däÛÃ\9bâ\82¬Ã\9b@>
-       <\0>
-       <\ 1>
-       <\0>
-       <\ 1>
+       00000000  3C 64 E4 DB C3 9B E2 82 - AC C3 9B 40 3E 0A 3C 00  |<d.........@>.<.|
+       00000010  3E 0A 3C 01 3E 0A 3C 00 - 3E 0A 3C 01 3E 0A        |>.<.>.<.>.<.>.|
 ---
 name: print-bksl-c
 description:
@@ -8773,6 +9542,7 @@ expected-stdout:
 name: print-crlf
 description:
        Check that CR+LF is shown and read as-is
+category: shell:textmode-no
 stdin:
        cat >foo <<-'EOF'
                x='bar\r
@@ -8795,6 +9565,32 @@ expected-stdout:
        {.5}
        {<bar\r}
 ---
+name: print-crlf-textmode
+description:
+       Check that CR+LF is treated as newline
+category: shell:textmode-yes
+stdin:
+       cat >foo <<-'EOF'
+               x='bar\r
+               ' #\r
+               echo .${#x} #\r
+               if test x"$KSH_VERSION" = x""; then #\r
+                       printf '<%s>' "$x" #\r
+               else #\r
+                       print -nr -- "<$x>" #\r
+               fi #\r
+       EOF
+       echo "[$("$__progname" foo)]"
+       "$__progname" foo | while IFS= read -r line; do
+               print -r -- "{$line}"
+       done
+expected-stdout:
+       [.4
+       <bar
+       >]
+       {.4}
+       {<bar}
+---
 name: print-lf
 description:
        Check that LF-only is shown and read as-is
@@ -8830,6 +9626,16 @@ stdin:
 expected-stdout-pattern:
        /^4 3 2 <> <\0>$/
 ---
+name: print-array
+description:
+       Check that print -A works as expected
+stdin:
+       print -An 0x20AC 0xC3 0xBC 8#101
+       set -U
+       print -A 0x20AC 0xC3 0xBC 8#102
+expected-stdout:
+       ¬Ã¼Aâ\82¬Ã\83¼B
+---
 name: print-escapes
 description:
        Check backslash expansion by the print builtin
@@ -8850,7 +9656,7 @@ stdin:
                        while [[ -n $line ]]; do
                                hv=1#${line::1}
                                if (( (pos & 15) == 0 )); then
-                                       (( pos )) && print "$dasc|"
+                                       (( pos )) && print -r -- "$dasc|"
                                        print -n "${pos#16#}  "
                                        dasc=' |'
                                fi
@@ -8868,7 +9674,7 @@ stdin:
                        print -n '   '
                        (( (pos++ & 15) == 7 )) && print -n -- '- '
                done
-               (( hv == 2147483647 )) || print "$dasc|"
+               (( hv == 2147483647 )) || print -r -- "$dasc|"
        }
 expected-stdout:
        00000000  5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27  |\ \!\"\#\$\%\&\'|
@@ -8877,13 +9683,13 @@ expected-stdout:
        00000030  20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C  | \9\:\;\<\=\>\?\|
        00000040  40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48  |@\A\B\C\D.\F\G\H|
        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|
-       00000060  5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C  |\Q\R\S\T \V\W\X\|
-       00000070  59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08  |Y\Z\[\]\^\_\`..|
-       00000080  20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B  |  \d..\g\h\i\j\k|
-       00000090  5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09  |\l\m.\o\p \q.\s.|
-       000000A0  0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20  |.\w\y\z\{\|\}\~ |
-       000000B0  E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20  |...d ... .3 x S |
-       000000C0  53 34 0A                -                          |S4.|
+       00000060  5C 51 5C 52 5C 53 5C 54 - 20 5C 55 5C 56 5C 57 5C  |\Q\R\S\T \U\V\W\|
+       00000070  58 5C 59 5C 5A 5C 5B 5C - 5C 5D 5C 5E 5C 5F 5C 60  |X\Y\Z\[\\]\^\_\`|
+       00000080  07 08 20 20 5C 64 1B 0C - 5C 67 5C 68 5C 69 5C 6A  |..  \d..\g\h\i\j|
+       00000090  5C 6B 5C 6C 5C 6D 0A 5C - 6F 5C 70 20 5C 71 0D 5C  |\k\l\m.\o\p \q.\|
+       000000A0  73 09 5C 75 0B 5C 77 5C - 78 5C 79 5C 7A 5C 7B 5C  |s.\u.\w\x\y\z\{\|
+       000000B0  7C 5C 7D 5C 7E 20 E2 82 - AC 64 20 EF BF BD 20 12  ||\}\~ ...d ... .|
+       000000C0  33 20 78 20 53 20 53 34 - 0A                       |3 x S S4.|
 ---
 name: dollar-doublequoted-strings
 description:
@@ -8925,7 +9731,7 @@ stdin:
                        while [[ -n $line ]]; do
                                hv=1#${line::1}
                                if (( (pos & 15) == 0 )); then
-                                       (( pos )) && print "$dasc|"
+                                       (( pos )) && print -r -- "$dasc|"
                                        print -n "${pos#16#}  "
                                        dasc=' |'
                                fi
@@ -8943,7 +9749,7 @@ stdin:
                        print -n '   '
                        (( (pos++ & 15) == 7 )) && print -n -- '- '
                done
-               (( hv == 2147483647 )) || print "$dasc|"
+               (( hv == 2147483647 )) || print -r -- "$dasc|"
        }
 expected-stdout:
        00000000  20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F  | !"#$%&'()*+,-./|
@@ -9016,6 +9822,17 @@ expected-exit: e != 0
 expected-stderr-pattern:
        /\.: missing argument.*\n.*source: missing argument/
 ---
+name: dot-errorlevel
+description:
+       Ensure dot resets $?
+stdin:
+       :>dotfile
+       (exit 42)
+       . ./dotfile
+       echo 1 $? .
+expected-stdout:
+       1 0 .
+---
 name: alias-function-no-conflict
 description:
        make aliases not conflict with function definitions
@@ -9242,7 +10059,7 @@ stdin:
                        while [[ -n $line ]]; do
                                hv=1#${line::1}
                                if (( (pos & 15) == 0 )); then
-                                       (( pos )) && print "$dasc|"
+                                       (( pos )) && print -r -- "$dasc|"
                                        print -n "${pos#16#}  "
                                        dasc=' |'
                                fi
@@ -9260,7 +10077,7 @@ stdin:
                        print -n '   '
                        (( (pos++ & 15) == 7 )) && print -n -- '- '
                done
-               (( hv == 2147483647 )) || print "$dasc|"
+               (( hv == 2147483647 )) || print -r -- "$dasc|"
        }
 expected-stdout:
        00000000  48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3  |Hello, World!\..|
@@ -9330,7 +10147,7 @@ stdin:
                                        dasc=$dasc$dch
                                        dch=
                                elif (( (pos & 7) == 0 )); then
-                                       (( pos )) && print "$dasc|"
+                                       (( pos )) && print -r -- "$dasc|"
                                        print -n "${pos#16#}  "
                                        dasc=' |'
                                fi
@@ -9345,7 +10162,7 @@ stdin:
                        print -n '     '
                        (( (pos++ & 7) == 3 )) && print -n -- '- '
                done
-               (( hv == 2147483647 )) || print "$dasc|"
+               (( hv == 2147483647 )) || print -r -- "$dasc|"
        }
 expected-stdout:
        00000000  0048 0065 006C 006C - 006F 002C 0020 0057  |Hello, W|
@@ -9411,7 +10228,7 @@ stdin:
                        while (( i < ${#line[*]} )); do
                                hv=${line[i++]}
                                if (( (pos & 15) == 0 )); then
-                                       (( pos )) && print "$dasc|"
+                                       (( pos )) && print -r -- "$dasc|"
                                        print -n "${pos#16#}  "
                                        dasc=' |'
                                fi
@@ -9428,7 +10245,7 @@ stdin:
                        print -n '   '
                        (( (pos++ & 15) == 7 )) && print -n -- '- '
                done
-               (( hv == 2147483647 )) || print "$dasc|"
+               (( hv == 2147483647 )) || print -r -- "$dasc|"
        }
 expected-stdout:
        00000000  48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3  |Hello, World!\..|
@@ -9494,7 +10311,7 @@ stdin:
                                        dasc=$dasc$dch
                                        dch=
                                elif (( (pos & 7) == 0 )); then
-                                       (( pos )) && print "$dasc|"
+                                       (( pos )) && print -r -- "$dasc|"
                                        print -n "${pos#16#}  "
                                        dasc=' |'
                                fi
@@ -9508,7 +10325,7 @@ stdin:
                        print -n '     '
                        (( (pos++ & 7) == 3 )) && print -n -- '- '
                done
-               (( hv == 2147483647 )) || print "$dasc|"
+               (( hv == 2147483647 )) || print -r -- "$dasc|"
        }
 expected-stdout:
        00000000  0048 0065 006C 006C - 006F 002C 0020 0057  |Hello, W|
@@ -9599,8 +10416,15 @@ expected-stdout:
 ---
 name: ulimit-1
 description:
+       Check that ulimit as used in dot.mksh works or is stubbed
+stdin:
+       ulimit -c 0
+---
+name: ulimit-2
+description:
        Check if we can use a specific syntax idiom for ulimit
-category: !os:syllable
+       XXX Haiku works, but only for -n and -V
+category: !os:haiku,!os:syllable
 stdin:
        if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
                #echo expected to fail on this OS
@@ -9645,7 +10469,6 @@ name: bashiop-1
 description:
        Check if GNU bash-like I/O redirection works
        Part 1: this is also supported by GNU bash
-category: shell:legacy-no
 stdin:
        exec 3>&1
        function threeout {
@@ -9666,7 +10489,6 @@ name: bashiop-2a
 description:
        Check if GNU bash-like I/O redirection works
        Part 2: this is *not* supported by GNU bash
-category: shell:legacy-no
 stdin:
        exec 3>&1
        function threeout {
@@ -9687,7 +10509,6 @@ name: bashiop-2b
 description:
        Check if GNU bash-like I/O redirection works
        Part 2: this is *not* supported by GNU bash
-category: shell:legacy-no
 stdin:
        exec 3>&1
        function threeout {
@@ -9708,7 +10529,6 @@ name: bashiop-2c
 description:
        Check if GNU bash-like I/O redirection works
        Part 2: this is supported by GNU bash 4 only
-category: shell:legacy-no
 stdin:
        echo mir >foo
        set -o noclobber
@@ -9732,7 +10552,6 @@ name: bashiop-3a
 description:
        Check if GNU bash-like I/O redirection fails correctly
        Part 1: this is also supported by GNU bash
-category: shell:legacy-no
 stdin:
        echo mir >foo
        set -o noclobber
@@ -9754,7 +10573,6 @@ name: bashiop-3b
 description:
        Check if GNU bash-like I/O redirection fails correctly
        Part 2: this is *not* supported by GNU bash
-category: shell:legacy-no
 stdin:
        echo mir >foo
        set -o noclobber
@@ -9778,7 +10596,6 @@ description:
        Check if GNU bash-like I/O redirection works
        Part 4: this is also supported by GNU bash,
        but failed in some mksh versions
-category: shell:legacy-no
 stdin:
        exec 3>&1
        function threeout {
@@ -9800,11 +10617,10 @@ expected-stdout:
        ras
        dwa
 ---
-name: bashiop-5-normal
+name: bashiop-5
 description:
        Check if GNU bash-like I/O redirection is only supported
        in !POSIX !sh mode as it breaks existing scripts' syntax
-category: shell:legacy-no
 stdin:
        :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
        :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
@@ -9814,43 +10630,6 @@ expected-stdout:
        2  = bar .
        3  = bar .
 ---
-name: bashiop-5-legacy
-description:
-       Check if GNU bash-like I/O redirection is not parsed
-       in lksh as it breaks existing scripts' syntax
-category: shell:legacy-yes
-stdin:
-       :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
-       :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
-       :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
-expected-stdout:
-       1  = bar .
-       2  = bar .
-       3  = bar .
----
-name: mkshiop-1
-description:
-       Check for support of more than 9 file descriptors
-category: !convfds
-stdin:
-       read -u10 foo 10<<< bar
-       echo x$foo
-expected-stdout:
-       xbar
----
-name: mkshiop-2
-description:
-       Check for support of more than 9 file descriptors
-category: !convfds
-stdin:
-       exec 12>foo
-       print -u12 bar
-       echo baz >&12
-       cat foo
-expected-stdout:
-       bar
-       baz
----
 name: oksh-eval
 description:
        Check expansions.
@@ -10085,7 +10864,8 @@ name: fd-cloexec-1
 description:
        Verify that file descriptors > 2 are private for Korn shells
        AT&T ksh93 does this still, which means we must keep it as well
-category: shell:legacy-no
+       XXX fails on some old Perl installations
+need-pass: no
 stdin:
        cat >cld <<-EOF
                #!$__perlname
@@ -10103,6 +10883,8 @@ name: fd-cloexec-2
 description:
        Verify that file descriptors > 2 are not private for POSIX shells
        See Debian Bug #154540, Closes: #499139
+       XXX fails on some old Perl installations
+need-pass: no
 stdin:
        cat >cld <<-EOF
                #!$__perlname
@@ -10116,22 +10898,6 @@ stdin:
 expected-stdout:
        Fowl
 ---
-name: fd-cloexec-3
-description:
-       Verify that file descriptors > 2 are not private for LEGACY KSH
-category: shell:legacy-yes
-stdin:
-       cat >cld <<-EOF
-               #!$__perlname
-               open(my \$fh, ">&", 9) or die "E: open \$!";
-               syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
-       EOF
-       chmod +x cld
-       exec 9>&1
-       ./cld
-expected-stdout:
-       Fowl
----
 name: comsub-1a
 description:
        COMSUB are now parsed recursively, so this works
@@ -10220,10 +10986,10 @@ expected-stdout:
        x() {
                case $1 in
                (u)
-                       echo x 
+                       \echo x 
                        ;|
                (*)
-                       echo $1 
+                       \echo $1 
                        ;;
                esac 
        } 
@@ -10231,20 +10997,36 @@ expected-stdout:
 name: comsub-5
 description:
        Check COMSUB works with aliases (does not expand them twice)
+       and reentrancy safety
 stdin:
        print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
        chmod +x pfn
        alias echo='echo a'
        foo() {
+               echo moo
                ./pfn "$(echo foo)"
        }
        ./pfn "$(echo b)"
+       typeset -f foo >x
+       cat x
+       foo
+       . ./x
        typeset -f foo
+       foo
 expected-stdout:
        a b
        foo() {
-               ./pfn "$(echo foo )" 
+               \echo a moo 
+               ./pfn "$(\echo a foo )" 
+       } 
+       a moo
+       a foo
+       foo() {
+               \echo a moo 
+               ./pfn "$(\echo a foo )" 
        } 
+       a moo
+       a foo
 ---
 name: comsub-torture
 description:
@@ -10355,56 +11137,56 @@ expected-stdout:
                vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4"
        }
        inline_TCOM() {
-               vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" 
+               vara=1 varb="2  3" \cmd arg1 $arg2 "$arg3  4" 
        } 
        function comsub_TCOM { x=$(
                vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4"
        ); }
        function comsub_TCOM {
-               x=$(vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" ) 
+               x=$(vara=1 varb="2  3" \cmd arg1 $arg2 "$arg3  4" ) 
        } 
        function reread_TCOM { x=$((
                vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4"
        )|tr u x); }
        function reread_TCOM {
-               x=$(( vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" ) | tr u x ) 
+               x=$( ( vara=1 varb="2  3" \cmd arg1 $arg2 "$arg3  4" ) | \tr u x ) 
        } 
        inline_TPAREN_TPIPE_TLIST() {
                (echo $foo  |  tr -dc 0-9; echo)
        }
        inline_TPAREN_TPIPE_TLIST() {
-               ( echo $foo | tr -dc 0-9 
-                 echo ) 
+               ( \echo $foo | \tr -dc 0-9 
+                 \echo ) 
        } 
        function comsub_TPAREN_TPIPE_TLIST { x=$(
                (echo $foo  |  tr -dc 0-9; echo)
        ); }
        function comsub_TPAREN_TPIPE_TLIST {
-               x=$(( echo $foo | tr -dc 0-9 ; echo ) ) 
+               x=$( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) 
        } 
        function reread_TPAREN_TPIPE_TLIST { x=$((
                (echo $foo  |  tr -dc 0-9; echo)
        )|tr u x); }
        function reread_TPAREN_TPIPE_TLIST {
-               x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x ) 
+               x=$( ( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) | \tr u x ) 
        } 
        inline_TAND_TOR() {
                cmd  &&  echo ja  ||  echo nein
        }
        inline_TAND_TOR() {
-               cmd && echo ja || echo nein 
+               \cmd && \echo ja || \echo nein 
        } 
        function comsub_TAND_TOR { x=$(
                cmd  &&  echo ja  ||  echo nein
        ); }
        function comsub_TAND_TOR {
-               x=$(cmd && echo ja || echo nein ) 
+               x=$(\cmd && \echo ja || \echo nein ) 
        } 
        function reread_TAND_TOR { x=$((
                cmd  &&  echo ja  ||  echo nein
        )|tr u x); }
        function reread_TAND_TOR {
-               x=$(( cmd && echo ja || echo nein ) | tr u x ) 
+               x=$( ( \cmd && \echo ja || \echo nein ) | \tr u x ) 
        } 
        inline_TSELECT() {
                select  file  in  *;  do  echo  "<$file>" ;  break ;  done
@@ -10412,21 +11194,21 @@ expected-stdout:
        inline_TSELECT() {
                select file in * 
                do
-                       echo "<$file>" 
-                       break 
+                       \echo "<$file>" 
+                       \break 
                done 
        } 
        function comsub_TSELECT { x=$(
                select  file  in  *;  do  echo  "<$file>" ;  break ;  done
        ); }
        function comsub_TSELECT {
-               x=$(select file in * ; do echo "<$file>" ; break ; done ) 
+               x=$(select file in * ; do \echo "<$file>" ; \break ; done ) 
        } 
        function reread_TSELECT { x=$((
                select  file  in  *;  do  echo  "<$file>" ;  break ;  done
        )|tr u x); }
        function reread_TSELECT {
-               x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x ) 
+               x=$( ( select file in * ; do \echo "<$file>" ; \break ; done ) | \tr u x ) 
        } 
        inline_TFOR_TTIME() {
                time  for  i  in  {1,2,3}  ;  do  echo  $i ;  done
@@ -10434,20 +11216,20 @@ expected-stdout:
        inline_TFOR_TTIME() {
                time for i in {1,2,3} 
                do
-                       echo $i 
+                       \echo $i 
                done 
        } 
        function comsub_TFOR_TTIME { x=$(
                time  for  i  in  {1,2,3}  ;  do  echo  $i ;  done
        ); }
        function comsub_TFOR_TTIME {
-               x=$(time for i in {1,2,3} ; do echo $i ; done ) 
+               x=$(time for i in {1,2,3} ; do \echo $i ; done ) 
        } 
        function reread_TFOR_TTIME { x=$((
                time  for  i  in  {1,2,3}  ;  do  echo  $i ;  done
        )|tr u x); }
        function reread_TFOR_TTIME {
-               x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x ) 
+               x=$( ( time for i in {1,2,3} ; do \echo $i ; done ) | \tr u x ) 
        } 
        inline_TCASE() {
                case  $foo  in  1)  echo eins;& 2) echo zwei  ;| *) echo kann net bis drei zählen;;  esac
@@ -10455,13 +11237,13 @@ expected-stdout:
        inline_TCASE() {
                case $foo in
                (1)
-                       echo eins 
+                       \echo eins 
                        ;&
                (2)
-                       echo zwei 
+                       \echo zwei 
                        ;|
                (*)
-                       echo kann net bis drei zählen 
+                       \echo kann net bis drei zählen 
                        ;;
                esac 
        } 
@@ -10469,13 +11251,13 @@ expected-stdout:
                case  $foo  in  1)  echo eins;& 2) echo zwei  ;| *) echo kann net bis drei zählen;;  esac
        ); }
        function comsub_TCASE {
-               x=$(case $foo in (1) echo eins  ;& (2) echo zwei  ;| (*) echo kann net bis drei zählen  ;; esac ) 
+               x=$(case $foo in (1) \echo eins  ;& (2) \echo zwei  ;| (*) \echo kann net bis drei zählen  ;; esac ) 
        } 
        function reread_TCASE { x=$((
                case  $foo  in  1)  echo eins;& 2) echo zwei  ;| *) echo kann net bis drei zählen;;  esac
        )|tr u x); }
        function reread_TCASE {
-               x=$(( case $foo in (1) echo eins  ;& (2) echo zwei  ;| (*) echo kann net bis drei zählen  ;; esac ) | tr u x ) 
+               x=$( ( case $foo in (1) \echo eins  ;& (2) \echo zwei  ;| (*) \echo kann net bis drei zählen  ;; esac ) | \tr u x ) 
        } 
        inline_TIF_TBANG_TDBRACKET_TELIF() {
                if  !  [[  1  =  1  ]]  ;  then  echo eins;  elif [[ 1 = 2 ]]; then echo zwei  ;else echo drei; fi
@@ -10483,25 +11265,25 @@ expected-stdout:
        inline_TIF_TBANG_TDBRACKET_TELIF() {
                if ! [[ 1 = 1 ]] 
                then
-                       echo eins 
+                       \echo eins 
                elif [[ 1 = 2 ]] 
                then
-                       echo zwei 
+                       \echo zwei 
                else
-                       echo drei 
+                       \echo drei 
                fi 
        } 
        function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
                if  !  [[  1  =  1  ]]  ;  then  echo eins;  elif [[ 1 = 2 ]]; then echo zwei  ;else echo drei; fi
        ); }
        function comsub_TIF_TBANG_TDBRACKET_TELIF {
-               x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) 
+               x=$(if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) 
        } 
        function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
                if  !  [[  1  =  1  ]]  ;  then  echo eins;  elif [[ 1 = 2 ]]; then echo zwei  ;else echo drei; fi
        )|tr u x); }
        function reread_TIF_TBANG_TDBRACKET_TELIF {
-               x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x ) 
+               x=$( ( if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) | \tr u x ) 
        } 
        inline_TWHILE() {
                i=1; while (( i < 10 )); do echo $i; let ++i; done
@@ -10509,24 +11291,24 @@ expected-stdout:
        inline_TWHILE() {
                i=1 
                while {
-                             \let] " i < 10 " 
+                             \\builtin let " i < 10 " 
                      } 
                do
-                       echo $i 
-                       let ++i 
+                       \echo $i 
+                       \let ++i 
                done 
        } 
        function comsub_TWHILE { x=$(
                i=1; while (( i < 10 )); do echo $i; let ++i; done
        ); }
        function comsub_TWHILE {
-               x=$(i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done ) 
+               x=$(i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) 
        } 
        function reread_TWHILE { x=$((
                i=1; while (( i < 10 )); do echo $i; let ++i; done
        )|tr u x); }
        function reread_TWHILE {
-               x=$(( i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done ) | tr u x ) 
+               x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) | \tr u x ) 
        } 
        inline_TUNTIL() {
                i=10; until  (( !--i )) ; do echo $i; done
@@ -10534,42 +11316,42 @@ expected-stdout:
        inline_TUNTIL() {
                i=10 
                until {
-                             \let] " !--i " 
+                             \\builtin let " !--i " 
                      } 
                do
-                       echo $i 
+                       \echo $i 
                done 
        } 
        function comsub_TUNTIL { x=$(
                i=10; until  (( !--i )) ; do echo $i; done
        ); }
        function comsub_TUNTIL {
-               x=$(i=10 ; until { \let] " !--i " ; } ; do echo $i ; done ) 
+               x=$(i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) 
        } 
        function reread_TUNTIL { x=$((
                i=10; until  (( !--i )) ; do echo $i; done
        )|tr u x); }
        function reread_TUNTIL {
-               x=$(( i=10 ; until { \let] " !--i " ; } ; do echo $i ; done ) | tr u x ) 
+               x=$( ( i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) | \tr u x ) 
        } 
        inline_TCOPROC() {
                cat  *  |&  ls
        }
        inline_TCOPROC() {
-               cat * |& 
-               ls 
+               \cat * |& 
+               \ls 
        } 
        function comsub_TCOPROC { x=$(
                cat  *  |&  ls
        ); }
        function comsub_TCOPROC {
-               x=$(cat * |&  ls ) 
+               x=$(\cat * |&  \ls ) 
        } 
        function reread_TCOPROC { x=$((
                cat  *  |&  ls
        )|tr u x); }
        function reread_TCOPROC {
-               x=$(( cat * |&  ls ) | tr u x ) 
+               x=$( ( \cat * |&  \ls ) | \tr u x ) 
        } 
        inline_TFUNCT_TBRACE_TASYNC() {
                function  korn  {  echo eins; echo zwei ;  }
@@ -10577,11 +11359,11 @@ expected-stdout:
        }
        inline_TFUNCT_TBRACE_TASYNC() {
                function korn {
-                       echo eins 
-                       echo zwei 
+                       \echo eins 
+                       \echo zwei 
                } 
                bourne() {
-                       logger * & 
+                       \logger * & 
                } 
        } 
        function comsub_TFUNCT_TBRACE_TASYNC { x=$(
@@ -10589,32 +11371,32 @@ expected-stdout:
                bourne  ()  {  logger *  &  }
        ); }
        function comsub_TFUNCT_TBRACE_TASYNC {
-               x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * &  } ) 
+               x=$(function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * &  } ) 
        } 
        function reread_TFUNCT_TBRACE_TASYNC { x=$((
                function  korn  {  echo eins; echo zwei ;  }
                bourne  ()  {  logger *  &  }
        )|tr u x); }
        function reread_TFUNCT_TBRACE_TASYNC {
-               x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * &  } ) | tr u x ) 
+               x=$( ( function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * &  } ) | \tr u x ) 
        } 
        inline_IOREAD_IOCAT() {
                tr  x  u  0<foo  >>bar
        }
        inline_IOREAD_IOCAT() {
-               tr x u <foo >>bar 
+               \tr x u <foo >>bar 
        } 
        function comsub_IOREAD_IOCAT { x=$(
                tr  x  u  0<foo  >>bar
        ); }
        function comsub_IOREAD_IOCAT {
-               x=$(tr x u <foo >>bar ) 
+               x=$(\tr x u <foo >>bar ) 
        } 
        function reread_IOREAD_IOCAT { x=$((
                tr  x  u  0<foo  >>bar
        )|tr u x); }
        function reread_IOREAD_IOCAT {
-               x=$(( tr x u <foo >>bar ) | tr u x ) 
+               x=$( ( \tr x u <foo >>bar ) | \tr u x ) 
        } 
        inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
                cat  >|bar  <<'EOFN'
@@ -10622,7 +11404,7 @@ expected-stdout:
        EOFN
        }
        inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
-               cat >|bar <<"EOFN" 
+               \cat >|bar <<"EOFN" 
                foo
        EOFN
        
@@ -10633,7 +11415,7 @@ expected-stdout:
        EOFN
        ); }
        function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
-               x=$(cat >|bar <<"EOFN" 
+               x=$(\cat >|bar <<"EOFN" 
                foo
        EOFN
        ) 
@@ -10644,10 +11426,10 @@ expected-stdout:
        EOFN
        )|tr u x); }
        function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
-               x=$(cat >|bar <<"EOFN" 
+               x=$( ( \cat >|bar <<"EOFN" 
                foo
        EOFN
-       ) | tr u x ) 
+       ) | \tr u x ) 
        } 
        inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
                cat  1>bar  <<-EOFI
@@ -10655,7 +11437,7 @@ expected-stdout:
                EOFI
        }
        inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
-               cat >bar <<-EOFI 
+               \cat >bar <<-EOFI 
        foo
        EOFI
        
@@ -10666,7 +11448,7 @@ expected-stdout:
                EOFI
        ); }
        function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
-               x=$(cat >bar <<-EOFI 
+               x=$(\cat >bar <<-EOFI 
        foo
        EOFI
        ) 
@@ -10677,46 +11459,46 @@ expected-stdout:
                EOFI
        )|tr u x); }
        function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
-               x=$(cat >bar <<-EOFI 
+               x=$( ( \cat >bar <<-EOFI 
        foo
        EOFI
-       ) | tr u x ) 
+       ) | \tr u x ) 
        } 
        inline_IORDWR_IODUP() {
                sh  1<>/dev/console  0<&1  2>&1
        }
        inline_IORDWR_IODUP() {
-               sh 1<>/dev/console <&1 2>&1 
+               \sh 1<>/dev/console <&1 2>&1 
        } 
        function comsub_IORDWR_IODUP { x=$(
                sh  1<>/dev/console  0<&1  2>&1
        ); }
        function comsub_IORDWR_IODUP {
-               x=$(sh 1<>/dev/console <&1 2>&1 ) 
+               x=$(\sh 1<>/dev/console <&1 2>&1 ) 
        } 
        function reread_IORDWR_IODUP { x=$((
                sh  1<>/dev/console  0<&1  2>&1
        )|tr u x); }
        function reread_IORDWR_IODUP {
-               x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x ) 
+               x=$( ( \sh 1<>/dev/console <&1 2>&1 ) | \tr u x ) 
        } 
        inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
                echo $(true) $((1+ 2)) ${  :;} ${| REPLY=x;}
        }
        inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
-               echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} 
+               \echo $(\true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} 
        } 
        function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
                echo $(true) $((1+ 2)) ${  :;} ${| REPLY=x;}
        ); }
        function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
-               x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) 
+               x=$(\echo $(\true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) 
        } 
        function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
                echo $(true) $((1+ 2)) ${  :;} ${| REPLY=x;}
        )|tr u x); }
        function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
-               x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x ) 
+               x=$( ( \echo $(\true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | \tr u x ) 
        } 
        inline_QCHAR_OQUOTE_CQUOTE() {
                echo fo\ob\"a\`r\'b\$az
@@ -10724,9 +11506,9 @@ expected-stdout:
                echo 'fo\ob\"a\`r'\''b\$az'
        }
        inline_QCHAR_OQUOTE_CQUOTE() {
-               echo fo\ob\"a\`r\'b\$az 
-               echo "fo\ob\"a\`r\'b\$az" 
-               echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" 
+               \echo fo\ob\"a\`r\'b\$az 
+               \echo "fo\ob\"a\`r\'b\$az" 
+               \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" 
        } 
        function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
                echo fo\ob\"a\`r\'b\$az
@@ -10734,7 +11516,7 @@ expected-stdout:
                echo 'fo\ob\"a\`r'\''b\$az'
        ); }
        function comsub_QCHAR_OQUOTE_CQUOTE {
-               x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) 
+               x=$(\echo fo\ob\"a\`r\'b\$az ; \echo "fo\ob\"a\`r\'b\$az" ; \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) 
        } 
        function reread_QCHAR_OQUOTE_CQUOTE { x=$((
                echo fo\ob\"a\`r\'b\$az
@@ -10742,7 +11524,7 @@ expected-stdout:
                echo 'fo\ob\"a\`r'\''b\$az'
        )|tr u x); }
        function reread_QCHAR_OQUOTE_CQUOTE {
-               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 ) 
+               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 ) 
        } 
        inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
                [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
@@ -10760,7 +11542,7 @@ expected-stdout:
                [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
        )|tr u x); }
        function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
-               x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x ) 
+               x=$( ( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | \tr u x ) 
        } 
        inline_heredoc_closed() {
                x=$(cat <<EOFN
@@ -10768,11 +11550,11 @@ expected-stdout:
        EOFN); echo $x
        }
        inline_heredoc_closed() {
-               x=$(cat <<EOFN 
+               x=$(\cat <<EOFN 
                note there must be no space between EOFN and )
        EOFN
        ) 
-               echo $x 
+               \echo $x 
        } 
        function comsub_heredoc_closed { x=$(
                x=$(cat <<EOFN
@@ -10780,10 +11562,10 @@ expected-stdout:
        EOFN); echo $x
        ); }
        function comsub_heredoc_closed {
-               x=$(x=$(cat <<EOFN 
+               x=$(x=$(\cat <<EOFN 
                note there must be no space between EOFN and )
        EOFN
-       ) ; echo $x ) 
+       ) ; \echo $x ) 
        } 
        function reread_heredoc_closed { x=$((
                x=$(cat <<EOFN
@@ -10791,10 +11573,10 @@ expected-stdout:
        EOFN); echo $x
        )|tr u x); }
        function reread_heredoc_closed {
-               x=$(( x=$(cat <<EOFN 
+               x=$( ( x=$(\cat <<EOFN 
                note there must be no space between EOFN and )
        EOFN
-       ) ; echo $x ) | tr u x ) 
+       ) ; \echo $x ) | \tr u x ) 
        } 
        inline_heredoc_space() {
                x=$(cat <<EOFN\ 
@@ -10802,11 +11584,11 @@ expected-stdout:
        EOFN ); echo $x
        }
        inline_heredoc_space() {
-               x=$(cat <<EOFN\  
+               x=$(\cat <<EOFN\  
                note the space between EOFN and ) is actually part of the here document marker
        EOFN 
        ) 
-               echo $x 
+               \echo $x 
        } 
        function comsub_heredoc_space { x=$(
                x=$(cat <<EOFN\ 
@@ -10814,10 +11596,10 @@ expected-stdout:
        EOFN ); echo $x
        ); }
        function comsub_heredoc_space {
-               x=$(x=$(cat <<EOFN\  
+               x=$(x=$(\cat <<EOFN\  
                note the space between EOFN and ) is actually part of the here document marker
        EOFN 
-       ) ; echo $x ) 
+       ) ; \echo $x ) 
        } 
        function reread_heredoc_space { x=$((
                x=$(cat <<EOFN\ 
@@ -10825,10 +11607,10 @@ expected-stdout:
        EOFN ); echo $x
        )|tr u x); }
        function reread_heredoc_space {
-               x=$(( x=$(cat <<EOFN\  
+               x=$( ( x=$(\cat <<EOFN\  
                note the space between EOFN and ) is actually part of the here document marker
        EOFN 
-       ) ; echo $x ) | tr u x ) 
+       ) ; \echo $x ) | \tr u x ) 
        } 
        inline_patch_motd() {
                x=$(sysctl -n kern.version | sed 1q)
@@ -10847,8 +11629,8 @@ expected-stdout:
                fi
        }
        inline_patch_motd() {
-               x=$(sysctl -n kern.version | sed 1q ) 
-               [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 
+               x=$(\sysctl -n kern.version | \sed 1q ) 
+               [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF 
        1,/^\$/d
        0a
        $x
@@ -10856,11 +11638,11 @@ expected-stdout:
        .
        wq
        EOF
-       )" = @(?) ]] && rm -f /etc/motd 
+       )" = @(?) ]] && \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 
+                       \install -c -o root -g wheel -m 664 /dev/null /etc/motd 
+                       \print -- "$x\n" >/etc/motd 
                fi 
        } 
        function comsub_patch_motd { x=$(
@@ -10880,7 +11662,7 @@ expected-stdout:
                fi
        ); }
        function comsub_patch_motd {
-               x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 
+               x=$(x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF 
        1,/^\$/d
        0a
        $x
@@ -10888,7 +11670,7 @@ expected-stdout:
        .
        wq
        EOF
-       )" = @(?) ]] && 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 ) 
+       )" = @(?) ]] && \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 ) 
        } 
        function reread_patch_motd { x=$((
                x=$(sysctl -n kern.version | sed 1q)
@@ -10907,7 +11689,7 @@ expected-stdout:
                fi
        )|tr u x); }
        function reread_patch_motd {
-               x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF 
+               x=$( ( x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF 
        1,/^\$/d
        0a
        $x
@@ -10915,7 +11697,7 @@ expected-stdout:
        .
        wq
        EOF
-       )" = @(?) ]] && 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 ) 
+       )" = @(?) ]] && \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 ) 
        } 
        inline_wdarrassign() {
                case x in
@@ -10926,7 +11708,7 @@ expected-stdout:
                case x in
                (x)
                        a+=b 
-                       \set -A c+ -- d e 
+                       \\builtin set -A c+ -- d e 
                        ;;
                esac 
        } 
@@ -10936,7 +11718,7 @@ expected-stdout:
                esac
        ); }
        function comsub_wdarrassign {
-               x=$(case x in (x) a+=b ; \set -A c+ -- d e  ;; esac ) 
+               x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e  ;; esac ) 
        } 
        function reread_wdarrassign { x=$((
                case x in
@@ -10944,7 +11726,7 @@ expected-stdout:
                esac
        )|tr u x); }
        function reread_wdarrassign {
-               x=$(( case x in (x) a+=b ; \set -A c+ -- d e  ;; esac ) | tr u x ) 
+               x=$( ( case x in (x) a+=b ; \\builtin set -A c+ -- d e  ;; esac ) | \tr u x ) 
        } 
 ---
 name: comsub-torture-io
@@ -11011,56 +11793,56 @@ expected-stdout:
                vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4" >&3
        }
        inline_TCOM() {
-               vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" >&3 
+               vara=1 varb="2  3" \cmd arg1 $arg2 "$arg3  4" >&3 
        } 
        function comsub_TCOM { x=$(
                vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4" >&3
        ); }
        function comsub_TCOM {
-               x=$(vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" >&3 ) 
+               x=$(vara=1 varb="2  3" \cmd arg1 $arg2 "$arg3  4" >&3 ) 
        } 
        function reread_TCOM { x=$((
                vara=1  varb='2  3'  cmd  arg1  $arg2  "$arg3  4" >&3
        )|tr u x); }
        function reread_TCOM {
-               x=$(( vara=1 varb="2  3" cmd arg1 $arg2 "$arg3  4" >&3 ) | tr u x ) 
+               x=$( ( vara=1 varb="2  3" \cmd arg1 $arg2 "$arg3  4" >&3 ) | \tr u x ) 
        } 
        inline_TPAREN_TPIPE_TLIST() {
                (echo $foo  |  tr -dc 0-9 >&3; echo >&3) >&3
        }
        inline_TPAREN_TPIPE_TLIST() {
-               ( echo $foo | tr -dc 0-9 >&3 
-                 echo >&3 ) >&3 
+               ( \echo $foo | \tr -dc 0-9 >&3 
+                 \echo >&3 ) >&3 
        } 
        function comsub_TPAREN_TPIPE_TLIST { x=$(
                (echo $foo  |  tr -dc 0-9 >&3; echo >&3) >&3
        ); }
        function comsub_TPAREN_TPIPE_TLIST {
-               x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) 
+               x=$( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) 
        } 
        function reread_TPAREN_TPIPE_TLIST { x=$((
                (echo $foo  |  tr -dc 0-9 >&3; echo >&3) >&3
        )|tr u x); }
        function reread_TPAREN_TPIPE_TLIST {
-               x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x ) 
+               x=$( ( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) | \tr u x ) 
        } 
        inline_TAND_TOR() {
                cmd  >&3 &&  >&3 echo ja  ||  echo >&3 nein
        }
        inline_TAND_TOR() {
-               cmd >&3 && echo ja >&3 || echo nein >&3 
+               \cmd >&3 && \echo ja >&3 || \echo nein >&3 
        } 
        function comsub_TAND_TOR { x=$(
                cmd  >&3 &&  >&3 echo ja  ||  echo >&3 nein
        ); }
        function comsub_TAND_TOR {
-               x=$(cmd >&3 && echo ja >&3 || echo nein >&3 ) 
+               x=$(\cmd >&3 && \echo ja >&3 || \echo nein >&3 ) 
        } 
        function reread_TAND_TOR { x=$((
                cmd  >&3 &&  >&3 echo ja  ||  echo >&3 nein
        )|tr u x); }
        function reread_TAND_TOR {
-               x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x ) 
+               x=$( ( \cmd >&3 && \echo ja >&3 || \echo nein >&3 ) | \tr u x ) 
        } 
        inline_TSELECT() {
                select  file  in  *;  do  echo  "<$file>" ;  break >&3 ;  done >&3
@@ -11068,21 +11850,21 @@ expected-stdout:
        inline_TSELECT() {
                select file in * 
                do
-                       echo "<$file>" 
-                       break >&3 
+                       \echo "<$file>" 
+                       \break >&3 
                done >&3 
        } 
        function comsub_TSELECT { x=$(
                select  file  in  *;  do  echo  "<$file>" ;  break >&3 ;  done >&3
        ); }
        function comsub_TSELECT {
-               x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) 
+               x=$(select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) 
        } 
        function reread_TSELECT { x=$((
                select  file  in  *;  do  echo  "<$file>" ;  break >&3 ;  done >&3
        )|tr u x); }
        function reread_TSELECT {
-               x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x ) 
+               x=$( ( select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) | \tr u x ) 
        } 
        inline_TFOR_TTIME() {
                for  i  in  {1,2,3}  ;  do  time  >&3 echo  $i ;  done >&3
@@ -11090,20 +11872,20 @@ expected-stdout:
        inline_TFOR_TTIME() {
                for i in {1,2,3} 
                do
-                       time echo $i >&3 
+                       time \echo $i >&3 
                done >&3 
        } 
        function comsub_TFOR_TTIME { x=$(
                for  i  in  {1,2,3}  ;  do  time  >&3 echo  $i ;  done >&3
        ); }
        function comsub_TFOR_TTIME {
-               x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) 
+               x=$(for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) 
        } 
        function reread_TFOR_TTIME { x=$((
                for  i  in  {1,2,3}  ;  do  time  >&3 echo  $i ;  done >&3
        )|tr u x); }
        function reread_TFOR_TTIME {
-               x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x ) 
+               x=$( ( for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) | \tr u x ) 
        } 
        inline_TCASE() {
                case  $foo  in  1)  echo eins >&3;& 2) echo zwei >&3  ;| *) echo kann net bis drei zählen >&3;;  esac >&3
@@ -11111,13 +11893,13 @@ expected-stdout:
        inline_TCASE() {
                case $foo in
                (1)
-                       echo eins >&3 
+                       \echo eins >&3 
                        ;&
                (2)
-                       echo zwei >&3 
+                       \echo zwei >&3 
                        ;|
                (*)
-                       echo kann net bis drei zählen >&3 
+                       \echo kann net bis drei zählen >&3 
                        ;;
                esac >&3 
        } 
@@ -11125,13 +11907,13 @@ expected-stdout:
                case  $foo  in  1)  echo eins >&3;& 2) echo zwei >&3  ;| *) echo kann net bis drei zählen >&3;;  esac >&3
        ); }
        function comsub_TCASE {
-               x=$(case $foo in (1) echo eins >&3  ;& (2) echo zwei >&3  ;| (*) echo kann net bis drei zählen >&3  ;; esac >&3 ) 
+               x=$(case $foo in (1) \echo eins >&3  ;& (2) \echo zwei >&3  ;| (*) \echo kann net bis drei zählen >&3  ;; esac >&3 ) 
        } 
        function reread_TCASE { x=$((
                case  $foo  in  1)  echo eins >&3;& 2) echo zwei >&3  ;| *) echo kann net bis drei zählen >&3;;  esac >&3
        )|tr u x); }
        function reread_TCASE {
-               x=$(( case $foo in (1) echo eins >&3  ;& (2) echo zwei >&3  ;| (*) echo kann net bis drei zählen >&3  ;; esac >&3 ) | tr u x ) 
+               x=$( ( case $foo in (1) \echo eins >&3  ;& (2) \echo zwei >&3  ;| (*) \echo kann net bis drei zählen >&3  ;; esac >&3 ) | \tr u x ) 
        } 
        inline_TIF_TBANG_TDBRACKET_TELIF() {
                if  !  [[  1  =  1  ]]  >&3 ;  then  echo eins;  elif [[ 1 = 2 ]] >&3; then echo zwei  ;else echo drei; fi >&3
@@ -11139,25 +11921,25 @@ expected-stdout:
        inline_TIF_TBANG_TDBRACKET_TELIF() {
                if ! [[ 1 = 1 ]] >&3 
                then
-                       echo eins 
+                       \echo eins 
                elif [[ 1 = 2 ]] >&3 
                then
-                       echo zwei 
+                       \echo zwei 
                else
-                       echo drei 
+                       \echo drei 
                fi >&3 
        } 
        function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
                if  !  [[  1  =  1  ]]  >&3 ;  then  echo eins;  elif [[ 1 = 2 ]] >&3; then echo zwei  ;else echo drei; fi >&3
        ); }
        function comsub_TIF_TBANG_TDBRACKET_TELIF {
-               x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) 
+               x=$(if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) 
        } 
        function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
                if  !  [[  1  =  1  ]]  >&3 ;  then  echo eins;  elif [[ 1 = 2 ]] >&3; then echo zwei  ;else echo drei; fi >&3
        )|tr u x); }
        function reread_TIF_TBANG_TDBRACKET_TELIF {
-               x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x ) 
+               x=$( ( if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) | \tr u x ) 
        } 
        inline_TWHILE() {
                i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
@@ -11165,24 +11947,24 @@ expected-stdout:
        inline_TWHILE() {
                i=1 
                while {
-                             \let] " i < 10 " 
+                             \\builtin let " i < 10 " 
                      } >&3 
                do
-                       echo $i 
-                       let ++i 
+                       \echo $i 
+                       \let ++i 
                done >&3 
        } 
        function comsub_TWHILE { x=$(
                i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
        ); }
        function comsub_TWHILE {
-               x=$(i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 ) 
+               x=$(i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) 
        } 
        function reread_TWHILE { x=$((
                i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
        )|tr u x); }
        function reread_TWHILE {
-               x=$(( i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x ) 
+               x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) | \tr u x ) 
        } 
        inline_TUNTIL() {
                i=10; until  (( !--i )) >&3 ; do echo $i; done >&3
@@ -11190,42 +11972,42 @@ expected-stdout:
        inline_TUNTIL() {
                i=10 
                until {
-                             \let] " !--i " 
+                             \\builtin let " !--i " 
                      } >&3 
                do
-                       echo $i 
+                       \echo $i 
                done >&3 
        } 
        function comsub_TUNTIL { x=$(
                i=10; until  (( !--i )) >&3 ; do echo $i; done >&3
        ); }
        function comsub_TUNTIL {
-               x=$(i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 ) 
+               x=$(i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) 
        } 
        function reread_TUNTIL { x=$((
                i=10; until  (( !--i )) >&3 ; do echo $i; done >&3
        )|tr u x); }
        function reread_TUNTIL {
-               x=$(( i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 ) | tr u x ) 
+               x=$( ( i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) | \tr u x ) 
        } 
        inline_TCOPROC() {
                cat  *  >&3 |&  >&3 ls
        }
        inline_TCOPROC() {
-               cat * >&3 |& 
-               ls >&3 
+               \cat * >&3 |& 
+               \ls >&3 
        } 
        function comsub_TCOPROC { x=$(
                cat  *  >&3 |&  >&3 ls
        ); }
        function comsub_TCOPROC {
-               x=$(cat * >&3 |&  ls >&3 ) 
+               x=$(\cat * >&3 |&  \ls >&3 ) 
        } 
        function reread_TCOPROC { x=$((
                cat  *  >&3 |&  >&3 ls
        )|tr u x); }
        function reread_TCOPROC {
-               x=$(( cat * >&3 |&  ls >&3 ) | tr u x ) 
+               x=$( ( \cat * >&3 |&  \ls >&3 ) | \tr u x ) 
        } 
        inline_TFUNCT_TBRACE_TASYNC() {
                function  korn  {  echo eins; echo >&3 zwei ;  }
@@ -11233,11 +12015,11 @@ expected-stdout:
        }
        inline_TFUNCT_TBRACE_TASYNC() {
                function korn {
-                       echo eins 
-                       echo zwei >&3 
+                       \echo eins 
+                       \echo zwei >&3 
                } 
                bourne() {
-                       logger * >&3 & 
+                       \logger * >&3 & 
                } 
        } 
        function comsub_TFUNCT_TBRACE_TASYNC { x=$(
@@ -11245,32 +12027,32 @@ expected-stdout:
                bourne  ()  {  logger *  >&3 &  }
        ); }
        function comsub_TFUNCT_TBRACE_TASYNC {
-               x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 &  } ) 
+               x=$(function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 &  } ) 
        } 
        function reread_TFUNCT_TBRACE_TASYNC { x=$((
                function  korn  {  echo eins; echo >&3 zwei ;  }
                bourne  ()  {  logger *  >&3 &  }
        )|tr u x); }
        function reread_TFUNCT_TBRACE_TASYNC {
-               x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 &  } ) | tr u x ) 
+               x=$( ( function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 &  } ) | \tr u x ) 
        } 
        inline_COMSUB_EXPRSUB() {
                echo $(true >&3) $((1+ 2))
        }
        inline_COMSUB_EXPRSUB() {
-               echo $(true >&3 ) $((1+ 2)) 
+               \echo $(\true >&3 ) $((1+ 2)) 
        } 
        function comsub_COMSUB_EXPRSUB { x=$(
                echo $(true >&3) $((1+ 2))
        ); }
        function comsub_COMSUB_EXPRSUB {
-               x=$(echo $(true >&3 ) $((1+ 2)) ) 
+               x=$(\echo $(\true >&3 ) $((1+ 2)) ) 
        } 
        function reread_COMSUB_EXPRSUB { x=$((
                echo $(true >&3) $((1+ 2))
        )|tr u x); }
        function reread_COMSUB_EXPRSUB {
-               x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x ) 
+               x=$( ( \echo $(\true >&3 ) $((1+ 2)) ) | \tr u x ) 
        } 
 ---
 name: funsub-1
@@ -11317,7 +12099,7 @@ stdin:
        echo "before:   x<$x> y<$y> z<$z> R<$REPLY>"
        x=${|
                local y
-               echo "begin:    x<$x> y<$y> z<$z> R<$REPLY>"
+               echo "start:    x<$x> y<$y> z<$z> R<$REPLY>"
                x=5
                y=6
                z=7
@@ -11332,7 +12114,7 @@ stdin:
        echo ${|true;}$(true).
 expected-stdout:
        before: x<1> y<2> z<3> R<4>
-       begin:  x<1> y<> z<3> R<>
+       start:  x<1> y<> z<3> R<>
        end:    x<5> y<6> z<7> R<8>
        after:  x<8> y<2> z<7> R<4>
        typeset t=$'foo\n\n'
@@ -11792,6 +12574,17 @@ expected-stdout:
        done
 expected-stderr-pattern: /.*-x.*option/
 ---
+name: utilities-getopts-3
+description:
+       Check unsetting OPTARG
+stdin:
+       set -- -x arg -y
+       getopts x:y opt && echo "${OPTARG-unset}"
+       getopts x:y opt && echo "${OPTARG-unset}"
+expected-stdout:
+       arg
+       unset
+---
 name: wcswidth-1
 description:
        Check the new wcswidth feature
@@ -12111,6 +12904,77 @@ expected-stdout:
        after   0='swc' 1='二' 2=''
        = done
 ---
+name: command-pvV-posix-priorities
+description:
+       For POSIX compatibility, command -v should find aliases and reserved
+       words, and command -p[vV] should find aliases, reserved words, and
+       builtins over external commands.
+stdin:
+       PATH=/bin:/usr/bin
+       alias foo="bar baz"
+       bar() { :; }
+       for word in 'if' 'foo' 'bar' 'set' 'true'; do
+               command -v "$word"
+               command -pv "$word"
+               command -V "$word"
+               command -pV "$word"
+       done
+expected-stdout:
+       if
+       if
+       if is a reserved word
+       if is a reserved word
+       alias foo='bar baz'
+       alias foo='bar baz'
+       foo is an alias for 'bar baz'
+       foo is an alias for 'bar baz'
+       bar
+       bar
+       bar is a function
+       bar is a function
+       set
+       set
+       set is a special shell builtin
+       set is a special shell builtin
+       true
+       true
+       true is a shell builtin
+       true is a shell builtin
+---
+name: whence-preserve-tradition
+description:
+       This regression test is to ensure that the POSIX compatibility
+       changes for 'command' (see previous test) do not affect traditional
+       'whence' behaviour.
+category: os:mirbsd
+stdin:
+       PATH=/bin:/usr/bin
+       alias foo="bar baz"
+       bar() { :; }
+       for word in 'if' 'foo' 'bar' 'set' 'true'; do
+               whence "$word"
+               whence -p "$word"
+               whence -v "$word"
+               whence -pv "$word"
+       done
+expected-stdout:
+       if
+       if is a reserved word
+       if not found
+       'bar baz'
+       foo is an alias for 'bar baz'
+       foo not found
+       bar
+       bar is a function
+       bar not found
+       set
+       set is a special shell builtin
+       set not found
+       true
+       /bin/true
+       true is a shell builtin
+       true is a tracked alias for /bin/true
+---
 name: duffs-device
 description:
        Check that the compiler did not optimise-break them
@@ -12183,7 +13047,7 @@ stdin:
        Copyright (C) 2002 Free Software Foundation, Inc.'
        EOF
        chmod +x bash
-       "$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="'
+       "$__progname" -xc 'foo=$(./bash --version 2>&1 | sed q); echo "=$foo="'
 expected-stdout:
        =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
 expected-stderr-pattern: