zsh-workers
 help / color / mirror / code / Atom feed
* Those two other alias bugs - w/fix for one
@ 2015-03-19  5:50 Bart Schaefer
  2015-03-20  2:27 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2015-03-19  5:50 UTC (permalink / raw)
  To: zsh-workers

workers/34668

torch% alias \{='print foo'

torch% {this is a test   
foothis is a test
torch% { foothis is a test

------------
workers/34682

% alias -g S='"'
% echo S abc def S
dquote> "
 abc def S

% echo S" abc def S
"

------------

Sadly these are not the same bug (though they must be related somewhere
in the re-parse-after-expansion pass).  Patch below fixes the first one
but not the second.  Maybe there's a better way that catches both.  No
promises that this doesn't do other weird things if you go too far down
the "alias -g" rabbit hole.

diff --git a/Src/lex.c b/Src/lex.c
index 1eb0bc7..42ccdfc 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1747,6 +1747,16 @@ checkalias(void)
 	if (an && !an->inuse &&
 	    ((an->node.flags & ALIAS_GLOBAL) ||
 	     (incmdpos && tok == STRING) || inalmore)) {
+	    if (!lexstop) {
+		/*
+		 * Tokens that don't require a space after, get one, else
+		 * we can't be sure to correctly lex the expansion text
+		 */
+		int c = hgetc();
+		hungetc(c);
+		if (!iblank(c))
+		    inpush(" ", INP_CONT, 0);
+	    }
 	    inpush(an->text, INP_ALIAS, an);
 	    if (an->text[0] == ' ' && !(an->node.flags & ALIAS_GLOBAL))
 		aliasspaceflag = 1;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-20  2:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-19  5:50 Those two other alias bugs - w/fix for one Bart Schaefer
2015-03-20  2:27 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).