You could’ve used bash’s exec which allows specifying argv0
# Sets PWD and SHLVL and the latter apparently can't be unset
env -i VARIABLE=value bash -c 'exec -a program ./program'
# Sets env's argv0, not my program's
bash -c 'exec -a program env -i VARIABLE=value ./program'
# SHLVL still set
env -i bash -c 'unset SHLVL; unset PWD; exec -a program ./program'
# SHLVL and _ still set
env -i zsh -c 'unset _ HOME PWD LOGNAME SHLVL OLDPWD; ARGV0=program
The original discussions, linked from my post:https://lists.gnu.org/archive/html/coreutils/2023-03/msg0000...
https://lists.gnu.org/archive/html/coreutils/2023-03/msg0001...
Here's the code if you wish to take a look:
https://github.com/lone-lang/lone#testing
https://github.com/lone-lang/lone/blob/master/scripts/test.b...
Without env -i, the folllowing tests would not be possible:
https://github.com/lone-lang/lone/blob/master/test/linux/env...
https://github.com/lone-lang/lone/blob/master/test/linux/env...
https://github.com/lone-lang/lone/blob/master/test/linux/env...
--argv0 STRING set argv[0] to STRING before running
Maybe that could be useful?/lib64/ld-linux-x86-64.so.2 --argv0 argv0isalie yourprogramm
ld is the (not dynamic) linker. It doesn't invoke your program at all.