From 2b1559056cf32c42675ecd937796e1455bcb5c2c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Jan 2017 08:13:21 +0100 Subject: hush: fix a bug in argv restoration after sourcing a file if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done. Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-misc/source_argv_and_shift.right | 4 ++++ shell/ash_test/ash-misc/source_argv_and_shift.tests | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 shell/ash_test/ash-misc/source_argv_and_shift.right create mode 100755 shell/ash_test/ash-misc/source_argv_and_shift.tests (limited to 'shell/ash_test/ash-misc') diff --git a/shell/ash_test/ash-misc/source_argv_and_shift.right b/shell/ash_test/ash-misc/source_argv_and_shift.right new file mode 100644 index 0000000..b15cc96 --- /dev/null +++ b/shell/ash_test/ash-misc/source_argv_and_shift.right @@ -0,0 +1,4 @@ +sourced_arg1:1 +arg1: +sourced_arg1:a +arg1:1 diff --git a/shell/ash_test/ash-misc/source_argv_and_shift.tests b/shell/ash_test/ash-misc/source_argv_and_shift.tests new file mode 100755 index 0000000..66353f3 --- /dev/null +++ b/shell/ash_test/ash-misc/source_argv_and_shift.tests @@ -0,0 +1,12 @@ +echo 'echo sourced_arg1:$1' >sourced1 +echo 'shift' >>sourced1 + +set -- 1 +. ./sourced1 +echo arg1:$1 + +set -- 1 +. ./sourced1 a +echo arg1:$1 + +rm sourced1 -- cgit v1.1