summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/shell/hush.c b/shell/hush.c
index e6c083f55..8baccf246 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7870,21 +7870,26 @@ static int FAST_FUNC builtin_shift(char **argv)
7870 7870
7871static int FAST_FUNC builtin_source(char **argv) 7871static int FAST_FUNC builtin_source(char **argv)
7872{ 7872{
7873 char *arg_path; 7873 char *arg_path, *filename;
7874 FILE *input; 7874 FILE *input;
7875 save_arg_t sv; 7875 save_arg_t sv;
7876#if ENABLE_HUSH_FUNCTIONS 7876#if ENABLE_HUSH_FUNCTIONS
7877 smallint sv_flg; 7877 smallint sv_flg;
7878#endif 7878#endif
7879 7879
7880 if (*++argv == NULL) 7880 arg_path = NULL;
7881 return EXIT_FAILURE; 7881 filename = *++argv;
7882 7882 if (!filename) {
7883 if (strchr(*argv, '/') == NULL && (arg_path = find_in_path(*argv)) != NULL) { 7883 /* bash says: "bash: .: filename argument required" */
7884 input = fopen_for_read(arg_path); 7884 return 2; /* bash compat */
7885 free(arg_path); 7885 }
7886 } else 7886 if (!strchr(filename, '/')) {
7887 input = fopen_or_warn(*argv, "r"); 7887 arg_path = find_in_path(filename);
7888 if (arg_path)
7889 filename = arg_path;
7890 }
7891 input = fopen_or_warn(filename, "r");
7892 free(arg_path);
7888 if (!input) { 7893 if (!input) {
7889 /* bb_perror_msg("%s", *argv); - done by fopen_or_warn */ 7894 /* bb_perror_msg("%s", *argv); - done by fopen_or_warn */
7890 return EXIT_FAILURE; 7895 return EXIT_FAILURE;