diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-09 08:22:06 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-09 08:22:06 +0100 |
commit | fb87d93d1e0a6760049fa88aadd1232b7e1545e7 (patch) | |
tree | 775402433f86553d91e78d0ef8ee9f0b0bee0bed /shell/ash.c | |
parent | 2b1559056cf32c42675ecd937796e1455bcb5c2c (diff) |
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>
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 6 |
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) int status = 0; char *fullname; char **argv; + char *args_need_save; struct strlist *sp; volatile struct shparam saveparam; @@ -12567,7 +12568,8 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM) */ fullname = find_dot_file(argv[0]); argv++; - if (argv[0]) { /* . FILE ARGS, ARGS exist */ + args_need_save = argv[0]; + if (args_need_save) { /* . FILE ARGS, ARGS exist */ int argc; saveparam = shellparam; shellparam.malloced = 0; @@ -12586,7 +12588,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM) status = cmdloop(0); popfile(); - if (argv[0]) { + if (args_need_save) { freeparam(&shellparam); shellparam = saveparam; }; |