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: Sat, 23 Jan 2016 23:53:02 +0000
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a string
Message-ID: <20160123235302.GB20278@tarsus.local2>
References: <20160115062648.GA14019@tarsus.local2>
 <20160115094117.5fcde75c@pwslap01u.europe.root.pri>
 <20160118022558.GC3979@tarsus.local2>
 <20160118104548.7db26f60@pwslap01u.europe.root.pri>
 <20160120074753.GA13624@tarsus.local2>
 <160120075917.ZM20024@torch.brasslantern.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <160120075917.ZM20024@torch.brasslantern.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Seq: zsh-workers 37752

Bart Schaefer wrote on Wed, Jan 20, 2016 at 07:59:17 -0800:
> On Jan 20,  7:47am, Daniel Shahaf wrote:
> }
> } bufferwords() received the "(x)" as a STRING token, so I looked further
> } down, into gettok().  The attached patch seems to do the trick [see the
> } added tests].  However, to paraphrase Knuth, I only tested this code,
> } not proved it correct.  I'd appreciate a review.
> 
> I haven't tried compiling with the patch, but of course the interesting
> test case is something like
> 
> repeat $( : complicated thing ending with; print $number ) (echo foo)
> 
> I.e. syntax is not "repeat TOKEN command" it's "repeat WORD command"

Seems fine:

% pz 'repeat $(( 2 + 4 )) (x)'
'repeat'
'$(( 2 + 4 ))'
'('
'x'
')'

% pz 'repeat $( : foo bar; echo 4) (x)'
'repeat'
'$( : foo bar; echo 4)'
'('
'x'
')'

% pz 'repeat "1"'\''2'\''$(( 3 + 0 ))$((echo 4);)\ 5 (x)'
'repeat'
$'"1"\'2\'$(( 3 + 0 ))$((echo 4);)\\ 5'
'('
'x'
')'

Shall I commit this and wait for bug reports?

