On Thu, 26 Jan 2023, 09:37 Sergei Trofimovich, <sly...@gmail.com> wrote:

> To the bug: looks like 'exec -a' does not work for bash scripts, but does
> work for other executables.
>

Be aware that the kernel is responsible for interpreting #! lines, not bash.

The kernel does several steps when it encounters an executable that starts
with the bytes '#' and '!'.
1. replacing argv[0] with the exec path, and
2. read bytes up to the first newline, skipping leading and trailing
whitespace;
3. if interstitial whitespace is present, split into two words at the first
run of whitespace
4. push these latter strings onto the front of argv
5. replace the exec path with a copy of (the new) argb[0]
6. re-start the execve procedure

Failing to make the substitution in step 1 would leave the interpreter
running but with no idea how to open the script so that it could run it.

-Martin

>

Reply via email to