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

Re: [BUG] In reference to patch 39815, about (z) flag and $( parse error



On Oct 10,  6:19pm, Sebastian Gniazdowski wrote:
} Subject: Re: [BUG] In reference to patch 39815, about (z) flag and $( pars
}
} Following parses correctly with (z):
} 
} asmcmds+=(${(o)$(ls -1 | perl -alne 'echo foo')
} })
} dbpkgs+=(${(fo@)$(pacman -Qq)})
} 
} following doesn't:
} 
} asmcmds+=(${(o)$(ls -1 | perl -alne 'echo foo'
} )})
} dbpkgs+=(${(fo@)$(pacman -Qq)})
} 
} And looking further, it's about ")" being at the same line as $(

So the doc says that (Z:n:) "causes unquoted newlines to be treated as
ordinary whitespace" but in fact what it really does is cause newline
*not* to be converted into a separator; it is still labeled as its
own separate token, which confuses this parse.

The following fixes it, but it seems a hack -- is there a better way?

diff --git a/Src/lex.c b/Src/lex.c
index 8493d47..a7b71d6 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -308,8 +308,14 @@ zshlex(void)
 	isnewlin = 0;
     else
 	isnewlin = (inbufct) ? -1 : 1;
-    if (tok == SEMI || (tok == NEWLIN && !(lexflags & LEXFLAGS_NEWLINE)))
+    if (tok == SEMI)
 	tok = SEPER;
+    else if (tok == NEWLIN) {
+	if (lexflags & LEXFLAGS_NEWLINE)
+	    zshlex();
+	else
+	    tok = SEPER;
+    }
 }
 
 /**/



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