From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15754 invoked by alias); 25 Feb 2017 22:53:14 -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: 22499 Received: (qmail 12318 invoked from network); 25 Feb 2017 22:53:14 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f169.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.128.169):SA:0(0.4/5.0):. Processed in 0.689416 secs); 25 Feb 2017 22:53:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=FREEMAIL_FROM,FREEMAIL_REPLYTO, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: linux.tech.guy@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.169 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to; bh=ywzEpSWW4Pppd6fmx+rMZE6dHjpTGl6UT2huQ3yhUOc=; b=uSW6dKXrkrTye92nJmTyFnxpcSBI/eqvnlxwWxHZqALnetG8j34Nvo7tiXvbrYtaxk QZEtd5w6j/QSLk0XhdZrq09MEEEYMtNn9zaqAfr8cA3ilW2yxfwZqUZm19j7MbfFpofc mX2ER8kYV/TKquD6tGCoStiY3sB/S0+DnsKIFvy6bs9GWGFjM2yTDi4ICeeKneQk4LIw fp9XZp6gd9Cwddv/IBVm4qiefNjI6XlHaYSiQ75bdwGi6hrjmRfg736tWxr+FxxLTFyL 7ZJ7ZwKz5Fb98lIKi6zDi/tk3HIhAcGv+kwnZej9hlWzFF8XvVDRHIK0K1m2gSiRJtpb 5IwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to; bh=ywzEpSWW4Pppd6fmx+rMZE6dHjpTGl6UT2huQ3yhUOc=; b=WsWPv0d7H11yv9N01o/MGvPkw7Vzse6sQ5ZACoD9v4/aF9QYL7jYpc0I3Yv4Y7h+ol 56DT082EuPn6A7CBiyWsuEnHTWvWhIo/rggLWpSY+v/dCNDCRQ0HH0wU7VLuI9QVF5Wz rmMPVb1S2goDwMJnc6z9Lp1kuu8XZQU2Bque5AlkQDSWq/wOImUlv1MKXrp4DIQyv2ty HhtDwGMFm3TSY+I/Uz1Rpniqs3exzmW9IrHi6DMRDzS4r9Bg2hJapEW4bwUXQqoHQsdW f+5mPXgHnIKU6MQvaf2LKoMY2EdGbaeX1nN+kQFwmiB2QYhXTBP/FiOxn5+80zqKyrls PlGg== X-Gm-Message-State: AMke39mbDhHK8g64CgD1uWLGeR2M+KFUDK/G1A1SOsqKqsylKUEfV2N/JDwSBxBUF3a8X76sfrwa+jMLd97azg== X-Received: by 10.223.144.176 with SMTP id i45mr8106954wri.51.1488063187044; Sat, 25 Feb 2017 14:53:07 -0800 (PST) MIME-Version: 1.0 Reply-To: linuxtechguy@gmail.com In-Reply-To: <170225141211.ZM20788@torch.brasslantern.com> References: <170225141211.ZM20788@torch.brasslantern.com> From: Jim Date: Sat, 25 Feb 2017 16:53:06 -0600 Message-ID: Subject: Re: A bug or improperly formatted script To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=94eb2c059b70aad1fd054962b508 --94eb2c059b70aad1fd054962b508 Content-Type: text/plain; charset=UTF-8 On Sat, Feb 25, 2017 at 4:12 PM, Bart Schaefer wrote: > Yes, this is a known / traditional behavior, and it somewhat regularly > comes up in examples where a program has been tested only in the "more > than one element" cases. > > The problem is that nesting ${${...}} "wants" to treat the inner ${...} > as a scalar, and will do so unless something else forces it to be an > array. (f) doesn't accomplish that because $(dirs -v) produces only > one line of output with the final newline stripped, so there is nothing > for (f) to split on. (@) won't accomplish it because it only means > that things that are already arrays should remain so. > > So what can be done to force interpretation as an array here? Unless > someone else has a better solution, the answer is to forcibly assign > the result to an array variable: > > print $((${${(z)${(Af)reply::="$(dirs -v)"}[-1]}[1]} + 1)) > Good to know. So in my original email the alternate example print $((${(z)${(fO)"$(dirs -v)"}[1][1]} + 1)) was this forcing it to an array or was it a fluke? I assumed(bad thing to do) that it had and "[1][1]" would then work properly. It does return the desired results for a single or multiple line output from "dirs -v". > Once we are expanding ${reply} rather than ${"$(dirs -v")} the array > property is preserved and [-1] remains an array subscript instead of > becoming a scalar string slice. > > A follow-up to this is going to zsh-workers. > I will forward this on to zsh-lovers. Thanks for your help. Jim --94eb2c059b70aad1fd054962b508--