From 992e0ff7e9a71a85a89d4fb7b4e6ace7ba74e2ba Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 29 Sep 2016 01:27:09 +0200 Subject: hush: fix ". EMPTY_LINE" not setting $? to 0 Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-misc/source3.right | 2 ++ shell/ash_test/ash-misc/source3.tests | 6 ++++++ shell/hush.c | 2 ++ shell/hush_test/hush-misc/source3.right | 2 ++ shell/hush_test/hush-misc/source3.tests | 6 ++++++ 5 files changed, 18 insertions(+) create mode 100644 shell/ash_test/ash-misc/source3.right create mode 100755 shell/ash_test/ash-misc/source3.tests create mode 100644 shell/hush_test/hush-misc/source3.right create mode 100755 shell/hush_test/hush-misc/source3.tests diff --git a/shell/ash_test/ash-misc/source3.right b/shell/ash_test/ash-misc/source3.right new file mode 100644 index 0000000..bdf9001 --- /dev/null +++ b/shell/ash_test/ash-misc/source3.right @@ -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 index 0000000..1abf156 --- /dev/null +++ b/shell/ash_test/ash-misc/source3.tests @@ -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 diff --git a/shell/hush.c b/shell/hush.c index e2b0a15..5698de6 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -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 index 0000000..bdf9001 --- /dev/null +++ b/shell/hush_test/hush-misc/source3.right @@ -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 index 0000000..1abf156 --- /dev/null +++ b/shell/hush_test/hush-misc/source3.tests @@ -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 -- cgit v1.1