From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18502 invoked by alias); 25 Apr 2013 01:29:39 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17775 Received: (qmail 1271 invoked from network); 25 Apr 2013 01:29:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at nkuitse.com does not designate permitted sender hosts) Date: Wed, 24 Apr 2013 21:29:20 -0400 From: Paul Hoffman To: zsh-users@zsh.org Subject: Re: How should I construct this? Message-ID: <20130425012920.GA692@phisen> Mail-Followup-To: zsh-users@zsh.org References: <130424125052.ZM15513@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) On Wed, Apr 24, 2013 at 06:40:25PM -0400, TJ Luoma wrote: > > > On 24 Apr 2013, at 15:50, Bart Schaefer wrote: > > >In addition to Thomas's hashtables remarks, zsh "for" also supports > >populating multiple variables each pass around the loop. > > > >So if you have an ordinary array like your example (BTW I hope those > >aren't your real passwords) then you can do > > > > for SSID WIFIPASS in $ALL_WIFI_NETWORKS > > do > > # Attempt to join network $SSID using $WIFIPASS > > done > > The only drawback that I have found to this is that it ignores "" for > empty passwords The "@" flag is your friend (see "Parameter Expansion Flags" in zshexpn): typeset -a wifi wifi=( ... ) for ssid pass in "${(@)wifi}"; do ...; done Sorry for the all-lower-case examples -- I'm lazy. Paul. -- Paul Hoffman