diff options
author | Denys Vlasenko | 2010-05-18 09:12:53 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-05-18 09:12:53 +0200 |
commit | e66cf821cf1e4bd8c1ef28445c0559269f69bab9 (patch) | |
tree | 3ab9c437fccd1b613570c5af054c6145278677f0 /shell/hush.c | |
parent | a1db8b8415cbac40c679a1ac11f90e97bf5a95f9 (diff) | |
download | busybox-e66cf821cf1e4bd8c1ef28445c0559269f69bab9.zip busybox-e66cf821cf1e4bd8c1ef28445c0559269f69bab9.tar.gz |
ash,hush: make bare "." set exitcode to 2
function old new delta
dotcmd 300 305 +5
builtin_source 176 171 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/shell/hush.c b/shell/hush.c index e6c083f..8baccf2 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -7870,21 +7870,26 @@ static int FAST_FUNC builtin_shift(char **argv) static int FAST_FUNC builtin_source(char **argv) { - char *arg_path; + char *arg_path, *filename; FILE *input; save_arg_t sv; #if ENABLE_HUSH_FUNCTIONS smallint sv_flg; #endif - if (*++argv == NULL) - return EXIT_FAILURE; - - if (strchr(*argv, '/') == NULL && (arg_path = find_in_path(*argv)) != NULL) { - input = fopen_for_read(arg_path); - free(arg_path); - } else - input = fopen_or_warn(*argv, "r"); + arg_path = NULL; + filename = *++argv; + if (!filename) { + /* bash says: "bash: .: filename argument required" */ + return 2; /* bash compat */ + } + if (!strchr(filename, '/')) { + arg_path = find_in_path(filename); + if (arg_path) + filename = arg_path; + } + input = fopen_or_warn(filename, "r"); + free(arg_path); if (!input) { /* bb_perror_msg("%s", *argv); - done by fopen_or_warn */ return EXIT_FAILURE; |