Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
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:date:message-id:subject:from:to
         :cc:content-type;
        bh=evmudEOoyaUiovWKRvHEqpQcOiCjvIpz6UKw2byy4BY=;
        b=s9xZ8O9I5YhholgQAYDNHUIiK5B2Xlhku0f4152FBr6rSYn+VTGS2BsZlP3ldDXpl8
         CAQwz3bxBwMiqaUWheya3MdBWDVIKGd6SRD8dEGDANjiNHJNGhD807Vc3bhQdKmUOcSK
         hhVqw9SiEjk6phHZWv20Qs7CxRX2teA9LpZcDSEPeX2QKEgzr1ojROEY5F/NSeE0V5U/
         UX/lWZ3ATYPNOFh8BYpLadggeMlD2x8yTEcKXe6/VG44N2536cyo5eBq+U5j0ucDXr9u
         Vk7Uav6/a2hitOc4TS4pv4yJExV9DqQkqKkFsnnorU9tKVQEbyVru/kRHOAI83bQhMeL
         lTnA==
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:date
         :message-id:subject:from:to:cc:content-type;
        bh=evmudEOoyaUiovWKRvHEqpQcOiCjvIpz6UKw2byy4BY=;
        b=PCOBVy8twiShVYiSXtb3hFgo3V2bBV0k0k4pR1pP9/h/R5rGx0gpyjxatzHQ6aIaHc
         tCFobOQq17fva6UjE7hZeQAFolZ62ILQS8/R14K54SeWzCZ6VlrJQtYQ9zVM00ghtyia
         YjGW+IouEvPUYhwYl4Ff8A3fXKqcHX3+qN4COvZJ1OXUnJY/DOv2O1OLUdC/08XPpVvk
         Re0+DMIngTyKD1Dawaj7c8+pPW/s8ZkjABWwpARLsrFlh9IftSEEDLRulf/2V6DvSzew
         TG11diqSBfcMRtcg4jrhxFJNq6Oq+37XsYH/qfqtBea5ewWHFOcwEuMMvTwfiPfDLrnQ
         KlJg==
X-Gm-Message-State: AG10YOROSi2Hurj9VGfsyWn2yz+0O/yMAFcmkMY3/qE8UrKkxGJcWvKgZ57HWXCZNrSR6M7gWyP8E6EF8i0Glg==
MIME-Version: 1.0
X-Received: by 10.28.195.212 with SMTP id t203mr18091538wmf.46.1453179364319;
 Mon, 18 Jan 2016 20:56:04 -0800 (PST)
In-Reply-To: <20160118022558.GC3979@tarsus.local2>
References: <20160115062648.GA14019@tarsus.local2>
	<20160115094117.5fcde75c@pwslap01u.europe.root.pri>
	<20160118022558.GC3979@tarsus.local2>
Date: Mon, 18 Jan 2016 20:56:04 -0800
Message-ID: <CAH+w=7Z7d9Xc2ro9F1cMoyT_TeqmVNYzZc0vOnrCchtRi_4VDQ@mail.gmail.com>
Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a string
From: Bart Schaefer <schaefer@brasslantern.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Peter Stephenson <p.stephenson@samsung.com>, Zsh hackers list <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
X-Seq: zsh-workers 37685

[Returning to the original topic of this thread ...]

On Sun, Jan 17, 2016 at 6:25 PM, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> What confuses me is that 'repeat 3 (x)' and 'repeat 3; do (x); done' are
> split differently. ;-)
>
> Shouldn't both of them treat the "(x)" the same way [either both of
> them considering it one unit, or both of them considering it three units]?

As Peter said earlier, the (z) flag does nothing but break the string
into syntactic shell words.  With the exception of "for" loops, which
are a weird special case because of "for ((...))", It does NOT
interpret shell keywords to parse any corresponding loop structures.
It knows a little about assignments and redirections but otherwise
reads lexical tokens in their most generic possible context; you can
think of it as having "lex" without "yacc" to drive it.

(z) also does not expand aliases, which means that even if it did
interpret keywords you could trivially break it by aliasing something
else to expand as "repeat" or vice-versa.  (In fact you can already
break the magic "for" parsing the same way.)

