Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Positional parameters and sourced files



On Sun, May 28, 2000 at 12:31:10AM +0000, Bart Schaefer wrote:
> Put these commands in /tmp/test.zsh:
> 
> 	echo $# $*
> 	set a b c d e
> 
> Now:
> 
> zsh% source /tmp/test.zsh ; echo $#
> 0
> 5
> zsh% source /tmp/test.zsh arg ; echo $#
> 1 arg
> 0
> 
> 
> So "set ..." in a sourced script changes the global positional parameters
> when the script is called with no arguments, but if it was called with any
> arguments then it changes only the locals.  This seems a bit odd.
> 
> Bash, on the other hand, always changes the global positional parameters,
> and further it throws away the local ones when the global ones are set.  I
> don't have ksh handy to try.
 
ksh behaves the same way as zsh. IMHO the bash behavior is the most
reasonable one.

Regards,
Bernd

-- 
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@xxxxxxxxxxxxxx
http://www.rrz.uni-hamburg.de/eggink/BEggink.html



Messages sorted by: Reverse Date, Date, Thread, Author