hush: fix 'eval ""' handling
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 28 Sep 2016 23:44:17 +0000 (01:44 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 28 Sep 2016 23:44:17 +0000 (01:44 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash_test/ash-misc/eval2.right [new file with mode: 0644]
shell/ash_test/ash-misc/eval2.tests [new file with mode: 0755]
shell/hush.c
shell/hush_test/hush-misc/eval2.right [new file with mode: 0644]
shell/hush_test/hush-misc/eval2.tests [new file with mode: 0755]

diff --git a/shell/ash_test/ash-misc/eval2.right b/shell/ash_test/ash-misc/eval2.right
new file mode 100644 (file)
index 0000000..a7ce6cc
--- /dev/null
@@ -0,0 +1,3 @@
+Zero:0
+Zero:0
+Zero:0
diff --git a/shell/ash_test/ash-misc/eval2.tests b/shell/ash_test/ash-misc/eval2.tests
new file mode 100755 (executable)
index 0000000..6bfb87a
--- /dev/null
@@ -0,0 +1,4 @@
+false; eval; echo Zero:$?
+false; eval ""; echo Zero:$?
+false; eval "
+"; echo Zero:$?
index 5698de6860eb660dcc118adce7ae000f9d619146..d7d152c104270f539aecf3a53f94d08dc55e98ab 100644 (file)
@@ -5679,7 +5679,7 @@ static char* expand_strvec_to_string(char **argv)
                        n++;
                }
        }
-       overlapping_strcpy((char*)list, list[0]);
+       overlapping_strcpy((char*)list, list[0] ? list[0] : "");
        debug_printf_expand("strvec_to_string='%s'\n", (char*)list);
        return (char*)list;
 }
diff --git a/shell/hush_test/hush-misc/eval2.right b/shell/hush_test/hush-misc/eval2.right
new file mode 100644 (file)
index 0000000..a7ce6cc
--- /dev/null
@@ -0,0 +1,3 @@
+Zero:0
+Zero:0
+Zero:0
diff --git a/shell/hush_test/hush-misc/eval2.tests b/shell/hush_test/hush-misc/eval2.tests
new file mode 100755 (executable)
index 0000000..6bfb87a
--- /dev/null
@@ -0,0 +1,4 @@
+false; eval; echo Zero:$?
+false; eval ""; echo Zero:$?
+false; eval "
+"; echo Zero:$?