diff options
author | Denys Vlasenko | 2013-03-17 14:11:04 +0100 |
---|---|---|
committer | Denys Vlasenko | 2013-03-17 14:11:04 +0100 |
commit | 88b532d59af81f3b788864b2d6d42e1f86bc8de0 (patch) | |
tree | 0dadcf6799131c15de084c828265ac17ac051b52 /shell/hush.c | |
parent | 4ef1439c593daadeffb3f00eaaf49e190a3039e1 (diff) | |
download | busybox-88b532d59af81f3b788864b2d6d42e1f86bc8de0.zip busybox-88b532d59af81f3b788864b2d6d42e1f86bc8de0.tar.gz |
hush: source builtin should override $N only if it has args
function old new delta
builtin_source 174 184 +10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index e2dc1e2..b233257 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -8880,6 +8880,9 @@ static int FAST_FUNC builtin_source(char **argv) free(arg_path); if (!input) { /* bb_perror_msg("%s", *argv); - done by fopen_or_warn */ + /* POSIX: non-interactive shell should abort here, + * not merely fail. So far no one complained :) + */ return EXIT_FAILURE; } close_on_exec_on(fileno(input)); @@ -8889,12 +8892,14 @@ static int FAST_FUNC builtin_source(char **argv) /* "we are inside sourced file, ok to use return" */ G.flag_return_in_progress = -1; #endif - save_and_replace_G_args(&sv, argv); + if (argv[1]) + save_and_replace_G_args(&sv, argv); parse_and_run_file(input); fclose(input); - restore_G_args(&sv, argv); + if (argv[1]) + restore_G_args(&sv, argv); #if ENABLE_HUSH_FUNCTIONS G.flag_return_in_progress = sv_flg; #endif |