From d94579abaf961fcad03cbd0468d0439752d2d206 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 6 Mar 2012 16:40:04 +0100 Subject: [PATCH] hush source: expand $PATH The behaviour of other shells suggest that with source or '.' the path should be resolved using the PATH environment variable. Do the same in barebox. Signed-off-by: Sascha Hauer --- common/hush.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/common/hush.c b/common/hush.c index 1dae0e82c..053d9a583 100644 --- a/common/hush.c +++ b/common/hush.c @@ -1678,10 +1678,25 @@ BAREBOX_CMD_END static int do_source(int argc, char *argv[]) { + char *path; + int ret; + if (argc < 2) return COMMAND_ERROR_USAGE; - return source_script(argv[1], argc - 1, argv + 1); + if (strchr(argv[1], '/')) { + path = xstrdup(argv[1]); + } else { + path = find_execable(argv[1]); + if (!path) + return 1; + } + + ret = source_script(path, argc - 1, argv + 1); + + free(path); + + return ret; } static const char *source_aliases[] = { ".", NULL};