ash testsuite: add most of hust tests which pass for ash

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/shell/ash_test/ash-vars/empty.right b/shell/ash_test/ash-vars/empty.right
new file mode 100644
index 0000000..2cb3c70
--- /dev/null
+++ b/shell/ash_test/ash-vars/empty.right
@@ -0,0 +1,3 @@
+a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F
+a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F
+a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F
diff --git a/shell/ash_test/ash-vars/empty.tests b/shell/ash_test/ash-vars/empty.tests
new file mode 100755
index 0000000..a9c247e
--- /dev/null
+++ b/shell/ash_test/ash-vars/empty.tests
@@ -0,0 +1,5 @@
+e=
+
+echo a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F
+echo a $e b $e c $e d $e e $e f $e 1 $e 2 $e 3 $e 4 $e 5 $e 6 $e 7 $e 8 $e 9 $e 0 $e A $e B $e C $e D $e E $e F
+echo $e a $e b $e c $e d $e e $e f $e 1 $e 2 $e 3 $e 4 $e 5 $e 6 $e 7 $e 8 $e 9 $e 0 $e A $e B $e C $e D $e E $e F
diff --git a/shell/ash_test/ash-vars/glob_and_vars.right b/shell/ash_test/ash-vars/glob_and_vars.right
new file mode 100644
index 0000000..3ac7ec5
--- /dev/null
+++ b/shell/ash_test/ash-vars/glob_and_vars.right
@@ -0,0 +1 @@
+./glob_and_vars.right ./glob_and_vars.tests
diff --git a/shell/ash_test/ash-vars/glob_and_vars.tests b/shell/ash_test/ash-vars/glob_and_vars.tests
new file mode 100755
index 0000000..482cf9d
--- /dev/null
+++ b/shell/ash_test/ash-vars/glob_and_vars.tests
@@ -0,0 +1,2 @@
+v=.
+echo $v/glob_and_vars.[tr]*
diff --git a/shell/ash_test/ash-vars/param_expand_len.right b/shell/ash_test/ash-vars/param_expand_len.right
new file mode 100644
index 0000000..96e8cb5
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_expand_len.right
@@ -0,0 +1,9 @@
+0
+0
+1
+Make sure len parsing doesnt break arg count
+0 0
+4 4
+Testing len op
+4 3 2 1 0 0
+0 3 0
diff --git a/shell/ash_test/ash-vars/param_expand_len.tests b/shell/ash_test/ash-vars/param_expand_len.tests
new file mode 100755
index 0000000..fe20a45
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_expand_len.tests
@@ -0,0 +1,17 @@
+"$THIS_SH" -c 'echo $#'
+"$THIS_SH" -c 'echo $#' arg0
+"$THIS_SH" -c 'echo $#' arg0 arg1
+
+echo Make sure len parsing doesnt break arg count
+set --
+echo $# ${#}
+set -- aaaa bbb cc d
+echo $# ${#}
+
+echo Testing len op
+echo ${#1} ${#2} ${#3} ${#4} ${#5} ${#6}
+
+unset e
+f=abc
+g=
+echo ${#e} ${#f} ${#g}
diff --git a/shell/ash_test/ash-vars/param_glob.right b/shell/ash_test/ash-vars/param_glob.right
new file mode 100644
index 0000000..bdee8fe
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_glob.right
@@ -0,0 +1,4 @@
+param_glob.tests
+param_glob.tests
+param_glob.t*
+param_glob.t*
diff --git a/shell/ash_test/ash-vars/param_glob.tests b/shell/ash_test/ash-vars/param_glob.tests
new file mode 100755
index 0000000..4d74fee
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_glob.tests
@@ -0,0 +1,9 @@
+if test $# = 0; then
+    exec "$THIS_SH" "$0" 'param_glob.t*'
+    echo NOT SHOWN
+    exit
+fi
+echo $*
+echo $@
+echo "$*"
+echo "$@"
diff --git a/shell/ash_test/ash-vars/param_subshell.right b/shell/ash_test/ash-vars/param_subshell.right
new file mode 100644
index 0000000..f3c3767
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_subshell.right
@@ -0,0 +1,7 @@
+1=1
+2=2
+3=3
+4=4
+5=5
+6=6
+7=7
diff --git a/shell/ash_test/ash-vars/param_subshell.tests b/shell/ash_test/ash-vars/param_subshell.tests
new file mode 100755
index 0000000..27fdc5b
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_subshell.tests
@@ -0,0 +1,15 @@
+if test $# = 0; then
+    "$THIS_SH" "$0" 1 2 3 4 5 6 7 8 9
+    exit
+fi
+echo 1=$1
+{ echo 2=$2; }
+{ echo 3=$3; } &
+# cant use usleep as it isnt standard in $PATH --
+# we fail when testing busybox compiled solely as "hush"
+wait
+( echo 4=$4 )
+( echo 5=$5 ) &
+wait
+true | echo 6=$6 | cat
+true | { echo 7=$7; } | cat
diff --git a/shell/ash_test/ash-vars/star.right b/shell/ash_test/ash-vars/star.right
new file mode 100644
index 0000000..0ecc55b
--- /dev/null
+++ b/shell/ash_test/ash-vars/star.right
@@ -0,0 +1,6 @@
+.1.
+.abc.
+.d.
+.e.
+.f.
+.1 abc d e f.
diff --git a/shell/ash_test/ash-vars/star.tests b/shell/ash_test/ash-vars/star.tests
new file mode 100755
index 0000000..5554c40
--- /dev/null
+++ b/shell/ash_test/ash-vars/star.tests
@@ -0,0 +1,8 @@
+if test $# = 0; then
+    exec "$THIS_SH" star.tests 1 abc 'd e f'
+fi
+# 'd e f' should be split into 3 separate args:
+for a in $*; do echo ".$a."; done
+
+# must produce .1 abc d e f.
+for a in "$*"; do echo ".$a."; done
diff --git a/shell/ash_test/ash-vars/var_expand_in_assign.right b/shell/ash_test/ash-vars/var_expand_in_assign.right
new file mode 100644
index 0000000..352210d
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_expand_in_assign.right
@@ -0,0 +1,5 @@
+. .
+.abc d e.
+.abc d e.
+.abc d e.
+.abc d e.
diff --git a/shell/ash_test/ash-vars/var_expand_in_assign.tests b/shell/ash_test/ash-vars/var_expand_in_assign.tests
new file mode 100755
index 0000000..18cdc74
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_expand_in_assign.tests
@@ -0,0 +1,15 @@
+if test $# = 0; then
+    exec "$THIS_SH" "$0" abc "d e"
+fi
+
+space=' '
+echo .$space.
+
+a=$*
+echo .$a.
+a=$@
+echo .$a.
+a="$*"
+echo .$a.
+a="$@"
+echo .$a.
diff --git a/shell/ash_test/ash-vars/var_expand_in_redir.right b/shell/ash_test/ash-vars/var_expand_in_redir.right
new file mode 100644
index 0000000..423299c
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_expand_in_redir.right
@@ -0,0 +1,3 @@
+TEST1
+TEST2
+TEST3
diff --git a/shell/ash_test/ash-vars/var_expand_in_redir.tests b/shell/ash_test/ash-vars/var_expand_in_redir.tests
new file mode 100755
index 0000000..bda6bdd
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_expand_in_redir.tests
@@ -0,0 +1,13 @@
+if test $# = 0; then
+    exec "$THIS_SH" "$0" abc "d e"
+fi
+
+echo TEST1 >"$1.out"
+echo TEST2 >"$2.out"
+# bash says: "$@.out": ambiguous redirect
+# ash handles it as if it is '$*' - we do the same
+echo TEST3 >"$@.out"
+
+cat abc.out "d e.out" "abc d e.out"
+
+rm abc.out "d e.out" "abc d e.out"
diff --git a/shell/ash_test/ash-vars/var_expand_on_ifs.right b/shell/ash_test/ash-vars/var_expand_on_ifs.right
new file mode 100644
index 0000000..2ed2069
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_expand_on_ifs.right
@@ -0,0 +1,9 @@
+1 a b c
+2 a + b c
+3 a b c
+4 a  b c
+5 a  b c
+6 a b + c
+7 a b c
+8 a b  c
+9 a b  c
diff --git a/shell/ash_test/ash-vars/var_expand_on_ifs.tests b/shell/ash_test/ash-vars/var_expand_on_ifs.tests
new file mode 100755
index 0000000..a12ff8e
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_expand_on_ifs.tests
@@ -0,0 +1,11 @@
+b=' b '
+e=''
+echo 1 a $b c
+echo 2 a +$b c
+echo 3 a $e$b c
+echo 4 a "$e"$b c
+echo 5 a ""$b c
+echo 6 a $b+ c
+echo 7 a $b$e c
+echo 8 a $b"$e" c
+echo 9 a $b"" c
diff --git a/shell/ash_test/ash-vars/var_in_pipes.right b/shell/ash_test/ash-vars/var_in_pipes.right
new file mode 100644
index 0000000..faf65be
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_in_pipes.right
@@ -0,0 +1,6 @@
+b=1
+b=2
+b=3
+b=4
+b=5
+b=6
diff --git a/shell/ash_test/ash-vars/var_in_pipes.tests b/shell/ash_test/ash-vars/var_in_pipes.tests
new file mode 100755
index 0000000..3f8cd27
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_in_pipes.tests
@@ -0,0 +1,7 @@
+b=1 env | grep ^b=
+true | b=2 env | grep ^b=
+a=1 true | b=3 env | grep ^b=
+
+(b=4 env) | grep ^b=
+(true | b=5 env) | grep ^b=
+(a=1 true | b=6 env) | grep ^b=
diff --git a/shell/ash_test/ash-vars/var_leaks.right b/shell/ash_test/ash-vars/var_leaks.right
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_leaks.right
@@ -0,0 +1 @@
+OK
diff --git a/shell/ash_test/ash-vars/var_leaks.tests b/shell/ash_test/ash-vars/var_leaks.tests
new file mode 100755
index 0000000..27c8c65
--- /dev/null
+++ b/shell/ash_test/ash-vars/var_leaks.tests
@@ -0,0 +1,14 @@
+# external program
+a=b /bin/true
+env | grep ^a=
+
+# builtin
+a=b true
+env | grep ^a=
+
+# exec with redirection only
+# in bash, this leaks!
+a=b exec 1>&1
+env | grep ^a=
+
+echo OK