From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23443 invoked by alias); 11 Oct 2016 04:18:59 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39602 Received: (qmail 7041 invoked from network); 11 Oct 2016 04:18:59 -0000 X-Qmail-Scanner-Diagnostics: from mail-qt0-f171.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.216.171):SA:0(0.0/5.0):. Processed in 0.792876 secs); 11 Oct 2016 04:18:59 -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.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=sf0ObxJJ+oZW/gm9BZp3FjcJznju7yd4Rie4CgqGrtQ=; b=ruR1f71n70M9Z2Zlaice/xQ+GO7U2P5JVTq8kXHVZg4tJ7vaPEgtywf0IicNawMZM3 kuZ8Aec9aIHBHb4Q6mw97HRhzHv+zwHkQfc3uwnrWDYU998R1tGQ1aaFKCzbvn2PacTa 8gDV66Sgfiu25zT21bkgF5dzsgtTq6mElnTbuTwBn5k/zUWe0FJFy36g/RVwh35S0A2Q /nAHSiIqjamteOk4XSfvUvI8iPG3kOZKtlq+qKUlbXaY1RWbTL9cwH3Tapzudht3EzbC +8i4437XvJ4GJUeJkSZ+yQriv+NwV6liOXFuilmURNQh5ZjQv2j92gLPdwnhRzfYoUrr iv1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=sf0ObxJJ+oZW/gm9BZp3FjcJznju7yd4Rie4CgqGrtQ=; b=SncZpQRxSyP4W1HLJ+KjMeuxcs8BfHZd2aYMfNFWRB49+KwKgdbBxJP9VsCyKGwgZO hVgkdsnZfVZ51Wk4GipvZK8zqgFNa3I3CgFJcGBFzVC11c+b4OlCyTQfhwdSIiB4pDnS Urx0LbaRGir3gESHsE20fJdAmbN5zZdkfR/64u+WdTHR0CyFRZmaXnZbV/YI17B+1zIK wW87BJo3irXoZjxUzEZEPVKOXHKSSrDwW4kEqgHl2cWn07RKOUMAwdGFQKKA3kURuprf iOcFHZY4h8qk7PVgeT4N6x++rOiKXM+YP/iN1ZOrJNdueeyYAscBin9soXNGPq7ShHBd NHYA== X-Gm-Message-State: AA6/9Rky1yVw5gf0QVz5Tw2jZS8H+eODk2E/JkB/hY5RIS6pzil2Kypx2gwRxftYnALeDc1+HmBOgQZrK4s7uw== X-Received: by 10.200.46.43 with SMTP id r40mr1360920qta.145.1476155917224; Mon, 10 Oct 2016 20:18:37 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20161008151244.GA7037@chaz.gmail.com> References: <20161008151244.GA7037@chaz.gmail.com> From: Bart Schaefer Date: Mon, 10 Oct 2016 20:18:36 -0700 Message-ID: Subject: Re: $^=var and leading/trailing blanks To: Zsh hackers list Content-Type: text/plain; charset=UTF-8 On Sat, Oct 8, 2016 at 8:12 AM, Stephane Chazelas wrote: > > Why the extra first and last element the the first two commands? This is sort of explained under the s:: expansion flag: For historical reasons, the usual behaviour that empty array elements are retained inside double quotes is disabled for arrays generated by splitting; hence the following: line="one::three" print -l "${(s.:.)line}" produces two lines of output for one and three and elides the empty field. To override this behaviour, supply the "(@)" flag as well, i.e. "${(@s.:.)line}". When you add the rcexpandparam flag, you get "the usual behavior" back again (otherwise an array of only empty elements would behave like an empty array and discard everything). When you nest the expansions, the inner split gets the empty elements removed when it expands, and then rcexpandparam applies to the remaining elements of that result. You don't get two elements for the two leading spaces because shwordsplit behaves that way. If you use (s: :) instead, then you do get one empty element for each space.