Patch by Jean Wolter to fix a bug where a script wouldnt be executed
authorGlenn L McGrath <bug1@ihug.co.nz>
Mon, 15 Sep 2003 12:00:19 +0000 (12:00 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Mon, 15 Sep 2003 12:00:19 +0000 (12:00 -0000)
unless it had #!/bin/sh in the first line

"It correctly locates the script, tries to execute it via execve which
fails. After that it tries to hand it over to /bin/sh which fails too,
since ash

    - neither provides the absolute pathname to /bin/sh
    - nor tries to lookup the script via PATH if called as "sh script"
"

shell/ash.c

index 59aa336..2146349 100644 (file)
@@ -3729,7 +3729,10 @@ repeat:
                for (ap = argv; *ap; ap++)
                        ;
                ap = new = ckmalloc((ap - argv + 2) * sizeof(char *));
-               *ap++ = cmd = (char *)DEFAULT_SHELL;
+               ap[1] = cmd;
+               *ap = cmd = (char *)DEFAULT_SHELL;
+               ap += 2;
+               argv++;
                while ((*ap++ = *argv++))
                        ;
                argv = new;