about summary refs log tree commit diff
path: root/Src/init.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-07-15 18:44:12 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-07-15 18:44:12 +0000
commit76aef28b3147fb5ea944c793452e2d5ca3b348fe (patch)
tree121357302f9a79c0a7452bd16b14d0f435159da1 /Src/init.c
parentaf0bfaea085e14f531a424e58d4276e426498e65 (diff)
downloadzsh-76aef28b3147fb5ea944c793452e2d5ca3b348fe.tar.gz
zsh-76aef28b3147fb5ea944c793452e2d5ca3b348fe.tar.xz
zsh-76aef28b3147fb5ea944c793452e2d5ca3b348fe.zip
28073: allow #! scripts to search path if interpreter not found
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/Src/init.c b/Src/init.c
index 06f177725..e85d3875a 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -949,25 +949,7 @@ setupshin(char *runscript)
 	     * With the PATHSCRIPT option, search the path if no
 	     * path was given in the script name.
 	     */
-	    char **pp, ppmaxlen = 0, *buf;
-	    for (pp = path; *pp; pp++)
-	    {
-		int len = strlen(*pp);
-		if (len > ppmaxlen)
-		    ppmaxlen = len;
-	    }
-	    buf = zhalloc(ppmaxlen + strlen(runscript) + 2);
-	    for (pp = path; *pp; pp++) {
-		sprintf(buf, "%s/%s", *pp, runscript);
-		/* careful, static buffer used in open() later */
-		funmeta = unmeta(buf);
-		if (access(funmeta, F_OK) == 0 &&
-		    stat(funmeta, &st) >= 0 &&
-		    !S_ISDIR(st.st_mode)) {
-		    sfname = buf;
-		    break;
-		}
-	    }
+	    funmeta = pathprog(runscript, &sfname);
 	}
 	if (!sfname ||
 	    (SHIN = movefd(open(funmeta, O_RDONLY | O_NOCTTY)))