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
Date: Mon, 18 Jan 2016 02:25:58 +0000
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh-workers@zsh.org
Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a string
Message-ID: <20160118022558.GC3979@tarsus.local2>
References: <20160115062648.GA14019@tarsus.local2>
 <20160115094117.5fcde75c@pwslap01u.europe.root.pri>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20160115094117.5fcde75c@pwslap01u.europe.root.pri>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Seq: zsh-workers 37662

Peter Stephenson wrote on Fri, Jan 15, 2016 at 09:41:17 +0000:
> 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.

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]?

> 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.

Even after reading your other reply, I still don't understand what
distinction you're trying to draw here, what case you say isn't expected
to work.  Could you clarify, please?

If you're asking whether I expect
    setopt NO_shortloops
    print -rl - ${(z):-"setopt shortloops; repeat 3 foo"}
to parse the "repeat 3 foo" part with shortloops set, the answer is no,
I don't expect that.

Thanks,

Daniel

> pws
> 

