Hi Vincent,

Vincent Lefevre wrote:
> Consider a script "script1" containing only the following line:
> 
> #!/usr/bin/env zsh
> 
> and a script "script2" containing:
> 
> echo Args: "$@"
> 
> The .zshenv file contains:
> 
> . ~/script2
> . ~/script2 blah
> 
> I get the following:
> 
> xvii% ./script1 ab cd ef
> Args: ab cd ef
> Args: blah

Looks as expected for me.

> The first line shouldn't show any argument because an empty list of
> positional parameters was provided in the ". ~/script2" line!

I think that's wrong.

Sourced scripts are no subshells and hence inherit all variables from
the script which sources it, including but not limited to $@, $*, $0,
$1, $2, etc. And I'm sure there are tons of scripts which rely on this
feature.

The second sourcing of script2 just overrides $@ and friends.

                Regards, Axel
-- 
 ,''`.  |  Axel Beckert <a...@debian.org>, http://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE
  `-    |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to