I have modified this patch per your review comments. For what it's worth, I
went through hush, and found that it still exhibits the BASH non-POSIXy
behavior. Take a look:

static char *find_in_path(const char *arg)
{
...
if (sz != 0) {
ret = xasprintf("%.*s/%s", sz, PATH, arg);
} else {
/* We have xxx::yyyy in $PATH,
* it means "use current dir" */
ret = xstrdup(arg);
}
if (access(ret, F_OK) == 0)
break;
...

----

static int FAST_FUNC builtin_source(char **argv)
{
...
if (!strchr(filename, '/')) {
arg_path = find_in_path(filename);
if (arg_path)
filename = arg_path;
}
...

----

 shell/ash.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git i/shell/ash.c w/shell/ash.c
index 865159d20..c9edce16c 100644
--- i/shell/ash.c
+++ w/shell/ash.c
@@ -60,6 +60,20 @@
 //config:      from GNU bash, which allows for alternative command not
found
 //config:      handling.
 //config:
+//config:config ASH_BASH_NON_POSIX_DOTCMD
+//config:      bool "non-POSIXy dotcmd behavior (ie: . <file> or source
<file>)"
+//config:      default n
+//config:      depends ASH_BASH_COMPAT
+//config:      help
+//config:      Activates the expected, non-POSIXy behavior BASH follows
when
+//config:      dotcmd is invoked with either ". <file>" or "source
<file>". In
+//config:      BASH, when the dotcmd is combined with a filename without an
+//config:      absolute or relative path specified, the shell first scans
the
+//config:      environment's PATH, followed by the present working
directory
+//config:      (PWD). The POSIX-compliant command does NOT scan the present
+//config:      working directory. This option is disabled by default for
improved
+//config:      speed and security.
+//config:
 //config:config ASH_JOB_CONTROL
 //config:      bool "Job control"
 //config:      default y
@@ -12967,7 +12981,10 @@ find_dot_file(char *name)
        if (strchr(name, '/'))
                return name;

-       while ((fullname = path_advance(&path, name)) != NULL) {
+    while ((fullname = path_advance(&path, name)) != NULL) {
+#if ASH_BASH_NON_POSIX_DOTCMD
+        try_cur_dir:
+#endif
                if ((stat(fullname, &statb) == 0) &&
S_ISREG(statb.st_mode)) {
                        /*
                         * Don't bother freeing here, since it will
@@ -12980,7 +12997,12 @@ find_dot_file(char *name)
        }

        /* not found in the PATH */
-       ash_msg_and_raise_error("%s: not found", name);
+#if ASH_BASH_NON_POSIX_DOTCMD
+    fullname = name;
+    goto try_cur_dir;
+#endif
+    /* not found at all */
+    ash_msg_and_raise_error("%s: not found", name);
        /* NOTREACHED */
 }
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to