Use the full path for noshebang'd scripts

If you make a script called `foo` somewhere in $PATH, and did not give
it a shebang, this would end up calling

    sh foo

instead of

    sh /usr/bin/foo

which might not match up.

Especially if the path is e.g. `--version` or `-` that would end up
being misinterpreted *by sh*.

So instead we simply pass the actual_cmd to sh, because we need it
anyway to get it to fail to execute before.
This commit is contained in:
Fabian Homborg
2021-12-02 21:10:57 +01:00
parent 0c76b571c7
commit 3700247b55
3 changed files with 19 additions and 1 deletions

View File

@@ -80,3 +80,13 @@ runfile
#CHECK: 126
#CHECKERR: exec: {{.*}}
echo 'echo foo' >./-
sleep 0.1
chmod +x ./-
set PATH ./ $PATH
sleep 0.1
-
#CHECK: foo
echo $status
#CHECK: 0