Subject: emulate -L sh impact on $0, $argv
From: Sebastian Gniazdowski <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Sun, 31 Jan 2016 19:03:40 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Hello
Is this expected behavior:

% echo 'echo Hello, my 0 is $0, argv0 is ${argv[0]}' > test_file.sh;
source() { emulate -L zsh; builtin source "$@"; }; source
./test_file.sh
Hello, my 0 is ./test_file.sh, argv0 is

% echo 'echo Hello, my 0 is $0, argv0 is ${argv[0]}' > test_file.sh;
source() { emulate -L sh; builtin source "$@"; }; source
./test_file.sh
Hello, my 0 is source, argv0 is ./test_file.sh

Sometimes -L zsh gives correct argv[0], couldn't clarify exactly when,
it may have something to do with reversed order of the calls.

Best regards,
Sebastian Gniazdowski