From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22323 invoked by alias); 31 Dec 2017 19:01:19 -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: List-Unsubscribe: X-Seq: 23042 Received: (qmail 15436 invoked by uid 1010); 31 Dec 2017 19:01:19 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f51.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(74.125.82.51):SA:0(-0.9/5.0):. Processed in 3.604974 secs); 31 Dec 2017 19:01:19 -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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FREEMAIL_REPLYTO,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,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: | 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=gsuSXm/rd83KhTfvF7awOy9/xg3SG5WVZh7Ph3TzrOM=; b=Sbi6kYdyypxLaTiyE0s2zidHBemfmaPn3/FDrp54uJTvCCOLasiXQ1fXrLNHLPUYT3 t7/ijv982YOJUbgnCZBDhwcbmIpZy9w1GlZWkoh1RZ7IK/4MC54YyhsIbyBBOxX9EP3I lDeh80pCPgHcXjxZn8LbviuEEsDFIWoBXipAXFWp9jpGDPsrQebw+Ki8mnV4v1mcSDPj ogl4YGTHumnAxcWqtpmbFjb/rDqLH/VMuCIlx5GkXlpzKEyiE9L05jGnrV+g8fEPQRZP K6DvjpaqwDcjivToVVNremcSWL9QrYw7/NldNCpgqvlGUvltON+fa+xadteiTY5L+XjC fElw== 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=gsuSXm/rd83KhTfvF7awOy9/xg3SG5WVZh7Ph3TzrOM=; b=d1z+Btqqr5X5W9HBbsm6XCfiSx1h00pnUYM22588lf6GsU1U1XYzXH8MtXlEeWIdso iyMNAQB+1LUPNfawBbeZD3mo7b4TfISrakX6GxPom6Y6/x5WfBm4CWcZ82WGW2ufqTLs 4Dmumwh4e52hSbuFmIvbTuCyLmM+fyKscoEoIRHc9uzz4V1+e72Gvo7zC2HgxGANHIA6 2sxWac8og2Aogt0QvqEN4nrNQ5oUIIaLj8mOZWZ3mrqbT1bn5RBROKOqN/eGT40OuElY M8s4zMF/CsV2s9Y5gqSx+uls2TyHNUwh+asS18Ek9ySpzAvzFujEFi34kWA7W+NLNNvf xEtg== X-Gm-Message-State: AKGB3mLfXCn9dk4Hj0RIKhv8YBle0B/cOh2dDeu5P50u5ijH5ciF+apF 7h2Tru2iNjSqAKo2ALqCR8P7B7Af3uu1mzqTTF0= X-Google-Smtp-Source: ACJfBotzFIlvh/Rbm50oxvUKncD62uupBmhSbfxKvZQDEERLP/0pCirqKE3hsauOOiXRwpsin7J0noqsjk0aDwTzg1M= X-Received: by 10.80.179.187 with SMTP id s56mr53125510edd.87.1514746870907; Sun, 31 Dec 2017 11:01:10 -0800 (PST) MIME-Version: 1.0 Reply-To: linuxtechguy@gmail.com In-Reply-To: References: From: Jim Date: Sun, 31 Dec 2017 13:01:10 -0600 Message-ID: Subject: Re: Mix and match parameter expansion flags and sub-scripting flags + quoting To: zsh Content-Type: multipart/alternative; boundary="94eb2c0ddd902a471a0561a77dc7" --94eb2c0ddd902a471a0561a77dc7 Content-Type: text/plain; charset="UTF-8" On Fri, Dec 29, 2017 at 12:43 PM, Bart Schaefer wrote: > On Fri, Dec 29, 2017 at 7:29 AM, Jim wrote: > > Hello, > > > > The intent is, using only "native zsh" tools, return the 'shell' > > as set in /etc/passwd for my own $USER without using any external > > utilities, gnu or otherwise. As in UNIX/Linux, zsh also has more then > > one way of doing the same thing. So as a training exercise I decided > > to use as many variants as I could to do the same thing. In the process > > I found that what I though would work, did not return the intended > > result. > > I haven't gone through your cases in any detail, but there are almost > certainly three things causing your problems: > (1) Nested expansions plus quoting cause an array in the inner > expansion to be joined into a string in most cases, unless you use > special syntax to preserve the array > (2) Single-element arrays behave like scalars (strings) in several cases > (3) Subscript syntax applies to scalars, to extract substrings > I can see this from my testing. > > Those last two put together can cause a lot of head-scratching. > > I believe I do my fair share, and not only on this. > > Figuring out at what level of a nested expansion you need to add (A) > or (@) is the other part of the equation. Sometimes you need to add > an extra level of nesting just to force (A) to be applied to the > correct value. > > AFAICT ..."${(f)"$(