<div dir="ltr"><div><font face="monospace, monospace">This patch restores, and improves upon, expected behavior to BASH compatibility which was lost beginning with 1.27.0. This was pulled into Alpine 3.7 which, in turn was pulled into official Docker images beginning with docker:17.12. As a result, a large number of CICD builds that use "source filename" have broken everywhere. </font></div><div><font face="monospace, monospace"><br></font></div><font face="monospace, monospace">According to the BASH documentation, the source command should:</font><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"></div></div></div></div></div></div></div></div></div></div></div></div></div>
<div><font face="monospace, monospace">Read and execute commands from filename  in  the  current  shell environment  and return the exit status of the last command executed from filename.  If filename does not contain a slash, filenames  in  PATH  are used to find the directory containing filename.  The file searched for in PATH  need  not  be  executable. When  bash  is  not  in  posix  mode,  the  current directory is searched if no file is found in PATH.<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">This patch specifically checks for when commandname is "source", and only performs the additional PWD search in that case, and only after it has neither 1) short-circuited from a /; and 2) not been found somewhere within the PATH.</font></div><div><font face="monospace, monospace"><br></font></div><div><div><div><font face="monospace, monospace"> shell/ash.c | 14 ++++++++++++--</font></div><div><font face="monospace, monospace"> 1 file changed, 12 insertions(+), 2 deletions(-)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">diff --git i/shell/ash.c w/shell/ash.c</font></div><div><font face="monospace, monospace">index 865159d20..6de68bc4d 100644</font></div><div><font face="monospace, monospace">--- i/shell/ash.c</font></div><div><font face="monospace, monospace">+++ w/shell/ash.c</font></div><div><font face="monospace, monospace">@@ -12967,7 +12967,10 @@ find_dot_file(char *name)</font></div><div><font face="monospace, monospace">        if (strchr(name, '/'))</font></div><div><font face="monospace, monospace">                return name;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">-       while ((fullname = path_advance(&path, name)) != NULL) {</font></div><div><font face="monospace, monospace">+    while ((fullname = path_advance(&path, name)) != NULL) {</font></div><div><font face="monospace, monospace">+#if BASH_SOURCE</font></div><div><font face="monospace, monospace">+        try_cur_dir:</font></div><div><font face="monospace, monospace">+#endif</font></div><div><font face="monospace, monospace">                if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) {</font></div><div><font face="monospace, monospace">                        /*</font></div><div><font face="monospace, monospace">                         * Don't bother freeing here, since it will</font></div><div><font face="monospace, monospace">@@ -12980,7 +12983,14 @@ find_dot_file(char *name)</font></div><div><font face="monospace, monospace">        }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">        /* not found in the PATH */</font></div><div><font face="monospace, monospace">-       ash_msg_and_raise_error("%s: not found", name);</font></div><div><font face="monospace, monospace">+#if BASH_SOURCE</font></div><div><font face="monospace, monospace">+    if (strcmp(commandname, "source") == 0) {</font></div><div><font face="monospace, monospace">+        fullname = name;</font></div><div><font face="monospace, monospace">+        goto try_cur_dir;</font></div><div><font face="monospace, monospace">+    }</font></div><div><font face="monospace, monospace">+#endif</font></div><div><font face="monospace, monospace">+    /* not found at all */</font></div><div><font face="monospace, monospace">+    ash_msg_and_raise_error("%s: not found", name);</font></div><div><font face="monospace, monospace">        /* NOTREACHED */</font></div><div><font face="monospace, monospace"> }</font></div></div></div><div><br></div></div>