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 autolearn=ham
	autolearn_force=no version=3.4.0
X-AuditID: cbfec7f5-f79b16d000005389-fa-5698bebe938f
Date: Fri, 15 Jan 2016 09:41:17 +0000
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a string
Message-id: <20160115094117.5fcde75c@pwslap01u.europe.root.pri>
In-reply-to: <20160115062648.GA14019@tarsus.local2>
References: <20160115062648.GA14019@tarsus.local2>
Organization: Samsung Cambridge Solution Centre
X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu)
MIME-version: 1.0
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7bit
X-Brightmail-Tracker:
 H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xK7r79s0IM3j4Sd/iYPNDJgdGj1UH
	PzAFMEZx2aSk5mSWpRbp2yVwZSyY8ICp4DNHRdvf7cwNjI3sXYycHBICJhJLFk2CssUkLtxb
	z9bFyMUhJLCUUWLdspmsEM4MJonF508xQjjnGCWm3N3HDuGcZZT48/o8WD+LgKrE01NPWEFs
	NgFDiambZjOC2CIC4hJn155nAbGFBXwlJvUfB6vnFbCXWLp8ApjNKWAscePfWWYQW0jASGL2
	gn1gNr+AvsTVv5+YIO6zl5h55QwjRK+gxI/J98BmMgtoSWze1sQKYctLbF7zFmqOusSNu7vZ
	JzAKz0LSMgtJyywkLQsYmVcxiqaWJhcUJ6XnGukVJ+YWl+al6yXn525ihAT01x2MS49ZHWIU
	4GBU4uH9wTkjTIg1say4MvcQowQHs5IIb/1ioBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHembve
	hwgJpCeWpGanphakFsFkmTg4pRoYrdn8vb6fN2CQMGZfEykstqim9lnjs++nIpjY2IPf53e8
	lS0IZ5ty5zDHPP/XCqIWy7S7VV38DxbkbSn9o2srbOXhMv1oxr/go85MLgyJ+mtWnGV2OtGx
	R2+n0sZLqSpnF+pV1mj9z+aI/y55a+WODe/lopmu3dl1frXGCtOI/ytkr7S8ibimxFKckWio
	xVxUnAgA+Dl+UWQCAAA=
X-Seq: zsh-workers 37641

On Fri, 15 Jan 2016 06:26:48 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> The ${(z)} modifier gives me a subshell as a single unit:

It doesn't know it's a subshell; it doesn't know you want the first
character to be in command position.  It's not parsing the whole thing
as a command expression, it's just splitting words, and (... ...) indeed
works as a complete word:

% noglob print -l one (two three) four
one
(two three)
four

The noglob hints at why parentheses not in command position are treated
like that --- it's convenient for glob qualifiers.

Having the parenthesised expressions in the strings

'one (two three) four'

and

'(two three)'

split in different ways by the same function typically would be confusing,
though it depends what you're doing with the result.

It might be possible to add a flag to cause an expression you pass in to
be split as if it were a complete command line, not just an arbitrary
set of arguments, but that's a whole new ball game.

If you're trying to make the (z) work as a kind of eval without
execution, I think you're expecting too much.

pws

