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

Re: path PATH



On Sun, Jan 22, 2023 at 10:57 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Sun, Jan 22, 2023 at 12:03 PM Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > % describe-params 0
> > scalar-special 0=describe-params
> >
> > Would it be better to use POSIX_ARGZERO to reveal the name of the
> > shell itself?  There's no way from inside a function to grab $0 from
> > the caller unless the caller itself asserts NO_FUNCTION_ARGZERO.
>
> Similar silliness that it may not be possible to fix, so maybe the
> above isn't worth considering:
>
> % describe-params '(#i)arg*' \?
> integer-readonly-special '!'=0
> integer-readonly-special '#'=10
> array-readonly-special '*'=( '*' - '?' @ _ '$' 0 ARGC argv )
> scalar-readonly-special -=569XZfims
> integer-readonly-special '?'=1
> array-readonly-special @=( @ _ '$' 0 ARGC argv )
> scalar-special _=_
> integer-readonly-special '$'=394907
> scalar-special 0=describe-params
> integer-readonly-special ARGC=2
> array-special argv=( argv )
>
> In case not obvious what I mean, $* and $@ and $argv should all have
> the same elements, and $# and $ARGC should be equal to one another and
> to the number of elements in the first three, but this can't be
> preserved while using ARGC and shift to walk the names.  Also, $? is
> nonzero because of the "if" test, and $_ is _ because that's the last
> word of the command that prints the value of $_.  It's like trying to
> examine quantum superposition.

I think it would be better for this function to pretend that those
function-scoped parameters don't exist. If it were a builtin, it could
describe parameters such as `ARGC` or `1` in a way that makes sense,
but here the caller can only get confused if any answer is returned
for them at all.

Roman.




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