hush: fix handling of empty arguments
function old new delta
builtin_exec 25 83 +58
parse_stream 2242 2261 +19
run_pipe 1782 1787 +5
static.pseudo_null_str - 3 +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 85/0) Total: 85 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/shell/hush_test/hush-misc/empty_args.right b/shell/hush_test/hush-misc/empty_args.right
new file mode 100644
index 0000000..38ed8b8
--- /dev/null
+++ b/shell/hush_test/hush-misc/empty_args.right
@@ -0,0 +1,6 @@
+Null 0th arg:
+hush: can't execute '': No such file or directory
+127
+Null 1st arg:
+0
+Null arg in exec:
diff --git a/shell/hush_test/hush-misc/empty_args.tests b/shell/hush_test/hush-misc/empty_args.tests
new file mode 100755
index 0000000..efce549
--- /dev/null
+++ b/shell/hush_test/hush-misc/empty_args.tests
@@ -0,0 +1,9 @@
+echo Null 0th arg:
+""
+echo $?
+echo Null 1st arg:
+# printf without args would print usage info
+printf ""
+echo $?
+echo Null arg in exec:
+exec printf ""
diff --git a/shell/hush_test/hush-psubst/emptytick.right b/shell/hush_test/hush-psubst/emptytick.right
index d4b70c5..1f60ecf 100644
--- a/shell/hush_test/hush-psubst/emptytick.right
+++ b/shell/hush_test/hush-psubst/emptytick.right
@@ -1,14 +1,17 @@
0
0
+hush: can't execute '': No such file or directory
+0
+hush: can't execute '': No such file or directory
0
0
0
0
0
+hush: can't execute '': No such file or directory
+0
+hush: can't execute '': No such file or directory
0
0
0
-0
-0
-0
-0
+hush: can't execute '': No such file or directory
diff --git a/shell/hush_test/hush-psubst/emptytick.tests b/shell/hush_test/hush-psubst/emptytick.tests
index af3a183..a269f02 100755
--- a/shell/hush_test/hush-psubst/emptytick.tests
+++ b/shell/hush_test/hush-psubst/emptytick.tests
@@ -1,16 +1,20 @@
true; ``; echo $?
false; ``; echo $?
+# UNFIXED BUG. bash sets $? to 127:
true; `""`; echo $?
+# bash sets $? to 127:
false; `""`; echo $?
true; ` `; echo $?
false; ` `; echo $?
true; $(); echo $?
false; $(); echo $?
+# bash sets $? to 127:
true; $(""); echo $?
+# bash sets $? to 127:
false; $(""); echo $?
true; $( ); echo $?
false; $( ); echo $?
-true; exec ''; echo $?
-false; exec ''; echo $?
+exec ''; echo $?
+echo Not reached