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

How does one describe $argv ?



On Feb 5, 8:27pm, I wrote:
}
}     binlink () {
}         argv=($^~==*(*))
}         ln -s "$PWD/$^@" /usr/local/bin
}     }

On Feb 4, 10:23pm, I wrote:
} 
} @@ -40,7 +40,8 @@
}  (Parameters are dynamically scoped.)  The tt(typeset) builtin, and its
}  alternative forms tt(declare), tt(integer), tt(local) and tt(readonly)
}  (but not tt(export)), can be used to declare a parameter as being local
} -to the innermost scope.
} +to the innermost scope.  Note that em(special) parameters cannot be made
} +local.

What's wrong with this picture?

In some sense, $argv is always local:

----------
zsh% set a b c
zsh% f() { echo $argv }
zsh% f

zsh% f x y z
x y z
zsh% echo $argv
a b c
----------

In some other sense, $argv is always global:

----------
zsh% set a b c
zsh% f() { unset argv }
zsh% f
zsh% echo $argv

zsh% echo $*
a b c
----------

I find that last bit especially puzzling; $argv is not set but $* is?  And
once you get into this state, "set" gets funny on you:

----------
zsh% set d e f
zsh% echo $*
d e f
zsh% echo $argv

zsh% argv=($*)
zsh% echo $argv
d e f
zsh% set a b c
zsh% echo $argv
a b c
----------

Somehow, I don't think the "Parameters Set By The Shell" entry for `argv'
even begins to be adequate to its task:

`argv' <S> <Z>
     Same as `*'.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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