hush: fix ". EMPTY_LINE" not setting $? to 0
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 28 Sep 2016 23:27:09 +0000 (01:27 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 28 Sep 2016 23:27:09 +0000 (01:27 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash_test/ash-misc/source3.right [new file with mode: 0644]
shell/ash_test/ash-misc/source3.tests [new file with mode: 0755]
shell/hush.c
shell/hush_test/hush-misc/source3.right [new file with mode: 0644]
shell/hush_test/hush-misc/source3.tests [new file with mode: 0755]

diff --git a/shell/ash_test/ash-misc/source3.right b/shell/ash_test/ash-misc/source3.right
new file mode 100644 (file)
index 0000000..bdf9001
--- /dev/null
@@ -0,0 +1,2 @@
+Zero:0
+Zero:0
diff --git a/shell/ash_test/ash-misc/source3.tests b/shell/ash_test/ash-misc/source3.tests
new file mode 100755 (executable)
index 0000000..1abf156
--- /dev/null
@@ -0,0 +1,6 @@
+# Test both empty file, and one-empty-line file
+echo >sourced1
+true >sourced2
+false; . ./sourced1; echo Zero:$?
+false; . ./sourced2; echo Zero:$?
+rm sourced1 sourced2
index e2b0a15b87b337a21777615759d869ecbb1736dd..5698de6860eb660dcc118adce7ae000f9d619146 100644 (file)
@@ -9156,6 +9156,8 @@ static int FAST_FUNC builtin_source(char **argv)
        if (argv[1])
                save_and_replace_G_args(&sv, argv);
 
+       /* "false; . ./empty_line; echo Zero:$?" should print 0 */
+       G.last_exitcode = 0;
        parse_and_run_file(input);
        fclose_and_forget(input);
 
diff --git a/shell/hush_test/hush-misc/source3.right b/shell/hush_test/hush-misc/source3.right
new file mode 100644 (file)
index 0000000..bdf9001
--- /dev/null
@@ -0,0 +1,2 @@
+Zero:0
+Zero:0
diff --git a/shell/hush_test/hush-misc/source3.tests b/shell/hush_test/hush-misc/source3.tests
new file mode 100755 (executable)
index 0000000..1abf156
--- /dev/null
@@ -0,0 +1,6 @@
+# Test both empty file, and one-empty-line file
+echo >sourced1
+true >sourced2
+false; . ./sourced1; echo Zero:$?
+false; . ./sourced2; echo Zero:$?
+rm sourced1 sourced2