From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13583 invoked by alias); 24 Apr 2013 22:40:33 -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: 17774 Received: (qmail 16187 invoked from network); 24 Apr 2013 22:40:32 -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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 66.111.4.221 is neither permitted nor denied by SPF record at _netblocks3.google.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :in-reply-to:references:mime-version:content-type; s=smtpout; bh=gWY8V0JkW9rmE1HoZUrlihPBF8I=; b=A0i59VYMXNnKojOH4Fh2in3iePb4 OBLJH+1M6wjM/WVy6LehEVCHnuwRvSlsyxnuSUKedXyhPQggwcu3gaDuCGJyHNmW i2aLukmJFqRE3sMrcxmaJeGMn80H/OUAR7usxQi4gF68wno2UU/G/+NVGHvvJqhG Pdf461k8nSOdWH0= X-Sasl-enc: 5y+0IDKS4m3Ssc/RryKv23EzVZ0DVxUpickQMMayqoXJ 1366843228 From: "TJ Luoma" To: "Zsh-Users List" Subject: Re: How should I construct this? Date: Wed, 24 Apr 2013 18:40:25 -0400 Message-ID: In-Reply-To: <130424125052.ZM15513@torch.brasslantern.com> References: <130424125052.ZM15513@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Mailer: MailMate Trial (1.5.4r3323) 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 # INPUT ALL_WIFI_NETWORKS=( "Home" "89382ashfa" "Work" "0823u2j98dyumn" "Coffee House" "" "Jenny's Wifi" "8675309" ) for SSID WIFIPASS in $ALL_WIFI_NETWORKS do echo "SSID: ${SSID}\tPass: ${WIFIPASS}\n" done # RESULTS SSID: Home Pass: 89382ashfa SSID: Work Pass: 0823u2j98dyumn SSID: Coffee House Pass: Jenny's Wifi SSID: 8675309 Pass: So I'll just use a single character to represent empty passwords, such as ALL_WIFI_NETWORKS=( "Home" "89382ashfa" "Work" "0823u2j98dyumn" "Coffee House" "-" "Jenny's Wifi" "8675309" ) for SSID WIFIPASS in $ALL_WIFI_NETWORKS do echo "SSID: ${SSID}\tPass: ${WIFIPASS}\n" done and then check for a password equal to - before sending the command. TjL