From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18278 invoked from network); 13 Dec 2000 04:04:55 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Dec 2000 04:04:55 -0000 Received: (qmail 16730 invoked by alias); 13 Dec 2000 04:04:43 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3561 Received: (qmail 16722 invoked from network); 13 Dec 2000 04:04:42 -0000 Date: Tue, 12 Dec 2000 22:04:37 -0600 From: Dan Nelson To: Steve Talley Cc: zsh-users@sunsite.auc.dk Subject: Re: Anonymous array indexing Message-ID: <20001212220437.A491@dan.emsphone.com> References: <20001212184156.I11810@rmtc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.12i In-Reply-To: <20001212184156.I11810@rmtc>; from "Steve Talley" on Tue Dec 12 18:41:56 GMT 2000 X-OS: FreeBSD 5.0-CURRENT 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@emsphone.com