Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Anonymous array indexing
- X-seq: zsh-users 3561
- From: Dan Nelson <dnelson@xxxxxxxxxxxx>
- To: Steve Talley <stephen.talley@xxxxxxx>
- Subject: Re: Anonymous array indexing
- Date: Tue, 12 Dec 2000 22:04:37 -0600
- Cc: zsh-users@xxxxxxxxxxxxxx
- In-reply-to: <20001212184156.I11810@rmtc>; from "Steve Talley" on Tue Dec 12 18:41:56 GMT 2000
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <20001212184156.I11810@rmtc>
In the last episode (Dec 12), Steve Talley said:
> Is there a compact version of the following:
>
> fred=(one two three)
> export FRED=$fred[2]
> unset fred
>
> I am looking for something like
>
> export FRED=(one two three)[2]
Assuming "one two three" is actually stored in a shell variable (we'll
call it a):
export FRED=${${=a}[2]}
will work. = turns on SH_WORD_SPLIT, essentially turning the variable
into an array temporarily.
--
Dan Nelson
dnelson@xxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author