[PATCH 5/8] hush source: expand $PATH
Sascha Hauer
s.hauer at pengutronix.de
Sun Mar 18 10:26:41 EDT 2012
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 at pengutronix.de>
---
common/hush.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/common/hush.c b/common/hush.c
index 1dae0e8..053d9a5 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};
--
1.7.9.1
More information about the barebox
mailing list