Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bufferwords() lexes a subshell in a shortloop repeat as a string



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?



Messages sorted by: Reverse Date, Date, Thread, Author