All pass.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
--- /dev/null
+if test $# = 0; then
+ exec "$THIS_SH" "$0" arg
+fi
+echo OK
--- /dev/null
+{abc}
+{
+}
+./brace1.tests: line 4: {cmd: not found
+./brace1.tests: line 5: {: not found
+./brace1.tests: line 6: {: not found
+Done: 127
--- /dev/null
+echo {abc}
+echo {
+echo }
+{cmd
+""{
+{""
+echo Done: $?
--- /dev/null
+{q,w}
+{q,w}
+Done
--- /dev/null
+v='{q,w}'
+# Should not brace-expand v value
+echo $v
+echo "$v"
+echo Done
--- /dev/null
+Nothing:
+String: #should-be-echoed
--- /dev/null
+echo Nothing: #should-not-be-echoed
+echo String: ""#should-be-echoed
--- /dev/null
+# bug was that we treated <newline> as ';' in this line:
+true || echo foo |
+echo BAD1 | cat
+
+# variation on the same theme
+true || echo foo |
+# comment
+echo BAD2 | cat
+
+# variation on the same theme
+true || echo foo |
+
+echo BAD3 | cat
+
+# this should error out, but currently works in hush:
+#true || echo foo |;
+
+echo Done:$?
--- /dev/null
+\
+a\b
+\\
+c\\d
--- /dev/null
+test "$CONFIG_FEATURE_FANCY_ECHO" = "y" || exit 77
+
+echo "\\"
+echo a"\\"b
+echo '\\'
+echo c'\\'d
--- /dev/null
+*?[a]*
+a*?[a]*b
+*?[a]*
+c*?[a]*d
--- /dev/null
+echo "*?[a]*"
+echo a"*?[a]*"b
+echo '*?[a]*'
+echo c'*?[a]*'d
--- /dev/null
+v: a \ b \\ c \\\ d \\\\ e
+v: a \ b \\ c \\\ d \\\\ e
+Unquoted:
+.a.
+.\.
+.b.
+.\\.
+.c.
+.\\\.
+.d.
+.\\\\.
+.e.
+Quoted:
+.a.
+.\.
+.b.
+.\\.
+.c.
+.\\\.
+.d.
+.\\\\.
+.e.
+done
--- /dev/null
+test "$CONFIG_FEATURE_FANCY_ECHO" = "y" || exit 77
+
+v='a \ b \\ c \\\ d \\\\ e'
+echo v: $v
+echo v: "$v"
+echo Unquoted:
+for a in $v; do echo .$a.; done
+echo Quoted:
+for a in $v; do echo ".$a."; done
+echo done
--- /dev/null
+i\
+f tr\
+ue; th\
+en echo "O\
+k"; fi; echo "\
+End"
\ No newline at end of file
--- /dev/null
+a\nb\nc\n
+a
+b
+c
+a\nb\nc\n
+a
+b
+c
+Done
--- /dev/null
+v="a\nb\nc\n"
+echo "$v"
+printf "$v"
+v='a\nb\nc\n'
+echo "$v"
+printf "$v"
+echo Done
--- /dev/null
+{ echo word} }; }
--- /dev/null
+got TERM
+Done: 0
--- /dev/null
+# Bug was in handling of "}&" without space
+{ trap "echo got TERM" TERM; sleep 2; }& sleep 1; kill $!; wait
+echo Done: $?
--- /dev/null
+Semicolons after } can be omitted 1:
+foo
+bar
+Semicolons after } can be omitted 2:
+foo
+bar
+Semicolons after fi can be omitted:
+foo
+bar
+baz
+Done:0
--- /dev/null
+echo "Semicolons after } can be omitted 1:"
+if { echo foo; } then { echo bar; } fi
+
+echo "Semicolons after } can be omitted 2:"
+while { echo foo; } do { echo bar; break; } done
+
+echo "Semicolons after fi can be omitted:"
+while if echo foo; then echo bar; fi do echo baz; break; done
+
+echo Done:$?
--- /dev/null
+! printing !
+0
+1
+1
+0
+0
+0
+!
+a
+b
+c
+! 1
+a 1
+b 1
+c 1
+! 1
+a 1
+b 1
+c 1
+0
+0
+0
+0
+1
+1
+1
+1
+0
+0
+0
+0
+1
+1
+1
+1
+Done
--- /dev/null
+echo ! printing !
+! false
+echo $?
+! true
+echo $?
+if ! false; then false; echo $?; fi
+echo $?
+if ! false; then ! false; echo $?; fi
+echo $?
+PRINTF=`which printf`
+for a in ! a b c; do echo $a; done
+for a in ! a b c; do ! printf "$a "; echo $?; done
+test x"$PRINTF" = x"" && exit 1
+for a in ! a b c; do ! "$PRINTF" "$a "; echo $?; done
+for a in ! a b c; do ! printf "$a " | false; echo $?; done
+for a in ! a b c; do ! printf "$a " | true; echo $?; done
+for a in ! a b c; do ! { printf "$a " | false; }; echo $?; done
+for a in ! a b c; do ! { printf "$a " | true; }; echo $?; done
+echo Done
--- /dev/null
+# next line has no EOL!
+echo HELLO
\ No newline at end of file
--- /dev/null
+# last line has no EOL!
+if true
+then
+ echo 1
+else
+ echo 2
+fi
\ No newline at end of file
--- /dev/null
+./noeol3.tests: line 2: syntax error: unterminated quoted string
--- /dev/null
+# last line has no EOL!
+echo "unterminated
\ No newline at end of file
--- /dev/null
+TESTzzBEST
+TEST$(echo zz)BEST
+TEST'BEST
--- /dev/null
+echo "TEST`echo zz;echo;echo`BEST"
+echo "TEST`echo '$(echo zz)'`BEST"
+echo "TEST`echo "'"`BEST"
--- /dev/null
+a=1
+echo "'$a'"
--- /dev/null
+a=1
+echo ">$a"
--- /dev/null
+Testing: in ""
+..
+Testing: in ''
+..
+Testing: in $empty
+Testing: in $empty""
+..
+Testing: in $empty''
+..
+Testing: in "$empty"
+..
+Finished
--- /dev/null
+empty=''
+
+echo 'Testing: in ""'
+for a in ""; do echo ".$a."; done
+
+echo 'Testing: in '"''"
+for a in ''; do echo ".$a."; done
+
+echo 'Testing: in $empty'
+for a in $empty; do echo ".$a."; done
+
+echo 'Testing: in $empty""'
+for a in $empty""; do echo ".$a."; done
+
+echo 'Testing: in $empty'"''"
+for a in $empty''; do echo ".$a."; done
+
+echo 'Testing: in "$empty"'
+for a in "$empty"; do echo ".$a."; done
+
+echo Finished
--- /dev/null
+a_b='a b'
+echo "$a_b"
--- /dev/null
+.1 abc d e f.
+.1.
+.abc.
+.d e f.
+.-1 abc d e f-.
+.-1.
+.abc.
+.d e f-.
--- /dev/null
+if test $# = 0; then
+ exec "$THIS_SH" "$0" 1 abc 'd e f'
+fi
+
+for a in "$*"; do echo ".$a."; done
+for a in "$@"; do echo ".$a."; done
+for a in "-$*-"; do echo ".$a."; done
+for a in "-$@-"; do echo ".$a."; done
--- /dev/null
+Should be printed
+Would not be printed by bash
+Would not be printed by bash
+Would not be printed by bash
+Should be printed
+Empty:
+Empty:
+Empty:
--- /dev/null
+if test $# != 0; then
+ exec "$THIS_SH" "$0"
+fi
+
+# No params!
+for a in "$*"; do echo Should be printed; done
+for a in "$@"; do echo Should not be printed; done
+# Yes, believe it or not, bash is mesmerized by "$@" and stops
+# treating "" as "this word cannot be expanded to nothing,
+# but must be at least null string". Now it can be expanded to nothing.
+for a in "$@"""; do echo Would not be printed by bash; done
+for a in """$@"; do echo Would not be printed by bash; done
+for a in """$@"''"$@"''; do echo Would not be printed by bash; done
+for a in ""; do echo Should be printed; done
+
+# Bug 207: "$@" expands to nothing, and we erroneously glob "%s\n" twice:
+printf 'Empty:%s\n' "$@"
+printf "Empty:%s\n" "$@"
+printf "Empty:%s\\n" "$@"
TOPDIR=`pwd`
-test -x ash || {
- echo "No ./ash - creating a link to ../../busybox"
- ln -s ../../busybox ash
-}
+if test ! -x ash; then
+ if test ! -x ../../busybox; then
+ echo "Can't run tests. Put ash binary into this directory (`pwd`)"
+ exit 1
+ fi
+ echo "No ./ash - creating a link to ../../busybox"
+ ln -s ../../busybox ash
+fi
+if test ! -f .config; then
+ if test ! -f ../../.config; then
+ echo "Missing .config file"
+ exit 1
+ fi
+ cp ../../.config . || exit 1
+fi
+
+eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
+
test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
test -x recho || gcc -O2 -o recho recho.c || exit $?
test -x zecho || gcc -O2 -o zecho zecho.c || exit $?