On Sun, 1 Sept 2024 at 12:43, Lockywolf < for_bug-bash_gnu.org_2024-09...@lockywolf.net> wrote:
> Dear Bash developers, > > May I ask for a small feature to be added to bash? > > At the moment exec changes IO redirections for the newly started > processes, but if there is no command for exec'ing, it changes those > redirections for the bash process itself. > > The exec -a, however, allows setting the current process title (argv0) > only for the newly exec'ed processes, and "exec -a whatever" (without a > command) does nothing. > Whilst I hesitate to justify choices on the basis of "consistency", i would argue that doing *nothing* is more consistent with what happens when exec is used to invoke a *script*, because in that case the execve kernel call will discard any supplied argv[0] and substitute either the given command pathname or (to safely support setuid scripts on some non-Linux systems) a magic path to a pre-opened filedescriptor. That said, there's virtually no downside to this, and it *might* be useful in some corner cases, as long as the script can tolerate the "do nothing" fallback on systems where this is less feasible to implement. -Martin