diff options
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index c69e4ec8a..5c5715b3f 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -9606,6 +9606,7 @@ static int FAST_FUNC builtin_source(char **argv) | |||
9606 | char *arg_path, *filename; | 9606 | char *arg_path, *filename; |
9607 | FILE *input; | 9607 | FILE *input; |
9608 | save_arg_t sv; | 9608 | save_arg_t sv; |
9609 | char *args_need_save; | ||
9609 | #if ENABLE_HUSH_FUNCTIONS | 9610 | #if ENABLE_HUSH_FUNCTIONS |
9610 | smallint sv_flg; | 9611 | smallint sv_flg; |
9611 | #endif | 9612 | #endif |
@@ -9637,7 +9638,8 @@ static int FAST_FUNC builtin_source(char **argv) | |||
9637 | /* "we are inside sourced file, ok to use return" */ | 9638 | /* "we are inside sourced file, ok to use return" */ |
9638 | G_flag_return_in_progress = -1; | 9639 | G_flag_return_in_progress = -1; |
9639 | #endif | 9640 | #endif |
9640 | if (argv[1]) | 9641 | args_need_save = argv[1]; /* used as a boolean variable */ |
9642 | if (args_need_save) | ||
9641 | save_and_replace_G_args(&sv, argv); | 9643 | save_and_replace_G_args(&sv, argv); |
9642 | 9644 | ||
9643 | /* "false; . ./empty_line; echo Zero:$?" should print 0 */ | 9645 | /* "false; . ./empty_line; echo Zero:$?" should print 0 */ |
@@ -9645,7 +9647,7 @@ static int FAST_FUNC builtin_source(char **argv) | |||
9645 | parse_and_run_file(input); | 9647 | parse_and_run_file(input); |
9646 | fclose_and_forget(input); | 9648 | fclose_and_forget(input); |
9647 | 9649 | ||
9648 | if (argv[1]) | 9650 | if (args_need_save) /* can't use argv[1] instead: "shift" can mangle it */ |
9649 | restore_G_args(&sv, argv); | 9651 | restore_G_args(&sv, argv); |
9650 | #if ENABLE_HUSH_FUNCTIONS | 9652 | #if ENABLE_HUSH_FUNCTIONS |
9651 | G_flag_return_in_progress = sv_flg; | 9653 | G_flag_return_in_progress = sv_flg; |