summaryrefslogtreecommitdiffstats
path: root/common/hush.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-03-06 16:40:04 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-03-18 15:03:31 +0100
commitd94579abaf961fcad03cbd0468d0439752d2d206 (patch)
treed84f6e69f0f7d4698cfaba3b10f51580e3af825a /common/hush.c
parent3f637f7dc4fb8b20ef30acc212653ea51bdaa418 (diff)
downloadbarebox-d94579abaf961fcad03cbd0468d0439752d2d206.tar.gz
barebox-d94579abaf961fcad03cbd0468d0439752d2d206.tar.xz
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 <s.hauer@pengutronix.de>
Diffstat (limited to 'common/hush.c')
-rw-r--r--common/hush.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/common/hush.c b/common/hush.c
index 1dae0e82cc..053d9a583e 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};