Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a string
From: Daniel Shahaf <[email-masked]>
To: Peter Stephenson <[email-masked]>
Cc: [email-masked]
Date: Mon, 18 Jan 2016 02:25:58 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

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
>