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>
This commit is contained in:
parent
2b1559056c
commit
fb87d93d1e
@ -12548,6 +12548,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM)
|
|||||||
int status = 0;
|
int status = 0;
|
||||||
char *fullname;
|
char *fullname;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
char *args_need_save;
|
||||||
struct strlist *sp;
|
struct strlist *sp;
|
||||||
volatile struct shparam saveparam;
|
volatile struct shparam saveparam;
|
||||||
|
|
||||||
@ -12567,7 +12568,8 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM)
|
|||||||
*/
|
*/
|
||||||
fullname = find_dot_file(argv[0]);
|
fullname = find_dot_file(argv[0]);
|
||||||
argv++;
|
argv++;
|
||||||
if (argv[0]) { /* . FILE ARGS, ARGS exist */
|
args_need_save = argv[0];
|
||||||
|
if (args_need_save) { /* . FILE ARGS, ARGS exist */
|
||||||
int argc;
|
int argc;
|
||||||
saveparam = shellparam;
|
saveparam = shellparam;
|
||||||
shellparam.malloced = 0;
|
shellparam.malloced = 0;
|
||||||
@ -12586,7 +12588,7 @@ dotcmd(int argc_ UNUSED_PARAM, char **argv_ UNUSED_PARAM)
|
|||||||
status = cmdloop(0);
|
status = cmdloop(0);
|
||||||
popfile();
|
popfile();
|
||||||
|
|
||||||
if (argv[0]) {
|
if (args_need_save) {
|
||||||
freeparam(&shellparam);
|
freeparam(&shellparam);
|
||||||
shellparam = saveparam;
|
shellparam = saveparam;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user