Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Evaluation of $# - bug?
- X-seq: zsh-users 3550
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: Re: Evaluation of $# - bug?
- Date: Mon, 4 Dec 2000 12:33:49 +0100 (MET)
- In-reply-to: Bernd Eggink's message of Mon, 4 Dec 2000 11:52:16 +0100
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
Bernd Eggink wrote:
> Hi,
>
> for some reasons
>
> set a b c
> print $argv[$#-1]
>
> prints nothing instead of "b", whereas both
>
> N=$#
> print $argv[$N-1]
>
> and
>
> print $argv[1,#-1]
>
> work as expected. Can anybody explain this behaviour, or is it a bug?
> It happens with 3.1.6 and 3.1.9-dev-7.
Always remember that there is a parameter named `-' (the option
string), so `$#-' gives the length of the value of that parameter and
`$#-1' gives that with a `1' stuck to the end.
Use `${#}-1'.
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author