aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-01-09 08:22:06 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-01-09 08:22:06 +0100
commitfb87d93d1e0a6760049fa88aadd1232b7e1545e7 (patch)
tree775402433f86553d91e78d0ef8ee9f0b0bee0bed
parent2b1559056cf32c42675ecd937796e1455bcb5c2c (diff)
downloadbusybox-w32-fb87d93d1e0a6760049fa88aadd1232b7e1545e7.tar.gz
busybox-w32-fb87d93d1e0a6760049fa88aadd1232b7e1545e7.tar.bz2
busybox-w32-fb87d93d1e0a6760049fa88aadd1232b7e1545e7.zip
ash: 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 <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index efb4615db..9c46a93e0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12548,6 +12548,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM)
12548 int status = 0; 12548 int status = 0;
12549 char *fullname; 12549 char *fullname;
12550 char **argv; 12550 char **argv;
12551 char *args_need_save;
12551 struct strlist *sp; 12552 struct strlist *sp;
12552 volatile struct shparam saveparam; 12553 volatile struct shparam saveparam;
12553 12554
@@ -12567,7 +12568,8 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM)
12567 */ 12568 */
12568 fullname = find_dot_file(argv[0]); 12569 fullname = find_dot_file(argv[0]);
12569 argv++; 12570 argv++;
12570 if (argv[0]) { /* . FILE ARGS, ARGS exist */ 12571 args_need_save = argv[0];
12572 if (args_need_save) { /* . FILE ARGS, ARGS exist */
12571 int argc; 12573 int argc;
12572 saveparam = shellparam; 12574 saveparam = shellparam;
12573 shellparam.malloced = 0; 12575 shellparam.malloced = 0;
@@ -12586,7 +12588,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM)
12586 status = cmdloop(0); 12588 status = cmdloop(0);
12587 popfile(); 12589 popfile();
12588 12590
12589 if (argv[0]) { 12591 if (args_need_save) {
12590 freeparam(&shellparam); 12592 freeparam(&shellparam);
12591 shellparam = saveparam; 12593 shellparam = saveparam;
12592 }; 12594 };