summaryrefslogtreecommitdiff
path: root/Src/exec.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/exec.c
parentaf0bfaea085e14f531a424e58d4276e426498e65 (diff)
downloadzsh-76aef28b3147fb5ea944c793452e2d5ca3b348fe.tar.gz
zsh-76aef28b3147fb5ea944c793452e2d5ca3b348fe.zip
28073: allow #! scripts to search path if interpreter not found
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 6611e9c79..73b4c01a8 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -461,8 +461,15 @@ zexecve(char *pth, char **argv, char **newenvp)
for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++);
for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++);
if (eno == ENOENT) {
+ char *pprog;
if (*ptr)
*ptr = '\0';
+ if (*ptr2 != '/' &&
+ (pprog = pathprog(ptr2, NULL))) {
+ argv[-2] = ptr2;
+ argv[-1] = ptr + 1;
+ execve(pprog, argv - 2, newenvp);
+ }
zerr("%s: bad interpreter: %s: %e", pth, ptr2,
eno);
} else if (*ptr) {