Description
In #2760, the runtime_env_toolchain interpreter wrapper script was changed to use exec -a
. While this works in most shells, it doesn't work in dash
shell, which is the usual default for Ubuntu/debian. That script strives to be posix-compatible, and exec -a
isn't posix.
It would appear our CI (and my local machine) use bash as a default for whatever reason.
Unfortunately, exec -a
will fail with an error in this case, so things break. As noted in the comment in the code, exec -a
is used to help trick python into respecting the virtual env when a wrapper script is used. It can probably be removed if need be because of the other "defense in depth" tricks used, but it'd be nice to retain it if possible.
I can't find a posix-compatible way to do exec -a
directly. There doesn't seem to be a clean/direct way to test if exec -a
is supported, either. Some ideas below
(exec -a true 2>/dev/null)
(c/o Alex Martani on Slack)
exec dash -c "$runprog" "newarg0" "$@"
might work, if we can detect the shell is dash.
Maybe the above, but using sh? sh -c ...
env -a
might work, but I'm not sure how available env
is or its -a
arg is.