2 ms·
Yep, it's a hack that depends on execvp behavior. I'm pretty sure I've seen a case in which a particular script worked when called directly from Bash, but not
by lambda 12y ago
Yep, it's a hack that depends on execvp behavior.
I'm pretty sure I've seen a case in which a particular script worked when called directly from Bash, but not when invoked by other things like xargs or nohup, because Bash actually will execute scripts under itself, while execvp will execute it under /bin/sh which is Dash on Debian/Ubuntu systems.
In fact, it was even better than that; they had even used #!/bin/bash, but had whitespace before it, causing the shebang to just be treated as a comment and not the as an interpreter:
https://stackoverflow.com/questions/24944405/why-is-the-following-bash-script-not-working-when-called-with-nohup https://stackoverflow.com/questions/24944405/why-is-the-foll...
Looks like it's fairly standard for shells to have this behavior, and execvp() is intended to have the behavior of executing like a shell would, so searching the path to find the executable and then passing the result to the shell interpreter if the underlying execve() returns noexec. May be a feature to add to your wacky homebrew shell.