Re: 'exec -a' and $0 substitution

2023-01-26 Thread Martin D Kealey
On Thu, 26 Jan 2023, 09:37 Sergei Trofimovich, 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 exec

Re: 'exec -a' and $0 substitution

2023-01-26 Thread Sergei Trofimovich
On Thu, 26 Jan 2023 00:35:27 -0500 Lawrence Velázquez wrote: > On Wed, Jan 25, 2023, at 6:37 PM, Sergei Trofimovich wrote: > > I fear it's a side-effect of the way 'bash' gets executed via shebang by > > kernel. But maybe not? Somehow direct script execution still manages to > > preserve script's

Re: 'exec -a' and $0 substitution

2023-01-25 Thread Lawrence Velázquez
On Wed, Jan 25, 2023, at 6:37 PM, Sergei Trofimovich wrote: > I fear it's a side-effect of the way 'bash' gets executed via shebang by > kernel. But maybe not? Somehow direct script execution still manages to > preserve script's name. Is it an intended behaviour that could not be > easily changed?

Re: 'exec -a' and $0 substitution

2023-01-25 Thread alex xmb ratchev
root@localhost:~# unset -v z ; cat srcpath ; bash srcpath ; ./srcpath ; "${z=$PWD/srcpath}" ; bash "$z" [[ ${z=$BASH_SOURCE} == /* ]] && t=$z || t=$PWD/$z printf %s\\n "$t" /root/srcpath /root/./srcpath /root/srcpath /root/srcpath On Thu, Jan 26, 2023, 12:51 AM Sergei Trofimovich wrote: > Hello

'exec -a' and $0 substitution

2023-01-25 Thread Sergei Trofimovich
Hello bash maintainers! nixpkgs package collection likes to wrap binaies and shell scripts to pass extra environment variables via wrappers. One example is dejagnu's runtest: $ cat `which runtest` | unnix #! /<>/bash-5.2-p15/bin/bash -e PATH=... export PATH exec -a "$0" "/<>/d