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

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



On Jan 18,  4:52pm, Peter Stephenson wrote:
} Subject: Re: bufferwords() lexes a subshell in a shortloop repeat as a str
}
} On Mon, 18 Jan 2016 08:36:58 -0800
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > print -l one (two three|foo) four
} 
} I was trying it with the (z) flag, which does cause the word to be
} split up, not directly at the command line, where I get what you get.
} 
} I don't know why they'd be different, offhand.

Seems to be that parameter substitution applies shwordsplit before (z)
gets involved, so we have separate calls to bufferwords() for each of
"one", "(two", "three|foo)" and "four".

Directly at command line, gettok() returns "\210two three\216four\212".

Does the below look correct?

schaefer[573] ARGV0=sh Src/zsh -f
$ print one (two three|four) five
zsh: parse error near `('
$ 


diff --git a/Src/lex.c b/Src/lex.c
index 0f260d0..c21ef2d 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -801,7 +801,7 @@ gettok(void)
 	    return INOUTPAR;
 	hungetc(d);
 	lexstop = 0;
-	if (!(incond == 1 || incmdpos))
+	if (!(isset(SHGLOB) || incond == 1 || incmdpos))
 	    break;
 	return INPAR;
     case LX1_OUTPAR:


Aside:  "emulate sh" does the equivalent of

    setopt shglob noglob nokshglob

In order to make kshglob work, one must

    setopt glob kshglob

Is that correct, or should only kshglob be needed?



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