zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] Alias with unclosed quote leaves incorrect string in history
@ 2015-03-07 22:11 ZyX
  2015-03-07 22:48 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: ZyX @ 2015-03-07 22:11 UTC (permalink / raw)
  To: zsh-workers

Given the following input:

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

%
===================================

if I press Up now it will show

===================================
% echo S" abc def S
"
===================================

which is the original string + a quote after first `S` which is wrong.

Second S also does not end the string, but I do not think this is a bug.

Tested on zsh -f with zsh-5.0.7-r2 (-r2 is an ebuild version, modified with patch from https://bugs.gentoo.org/show_bug.cgi?id=538684) and commit 0e319ecadc86a589c9f28819efae9e0bf972ee1b.

Same thing will happen if I e.g. have unclosed `$(` or `'` in an alias. I think it is more correct to deal with this problem by errorring out when user tries to use such an alias.


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

* Re: [BUG] Alias with unclosed quote leaves incorrect string in history
  2015-03-07 22:11 [BUG] Alias with unclosed quote leaves incorrect string in history ZyX
@ 2015-03-07 22:48 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2015-03-07 22:48 UTC (permalink / raw)
  To: zsh-workers

On Mar 8,  1:11am, ZyX wrote:
}
} % alias -g S='"'
} % echo S abc def S
} dquote> "
}  abc def S
} % echo S" abc def S
} "
} 
} which is the original string + a quote after first `S` which is wrong.

This is probably related to the bug with aliasing of "{" that I reported
as an afterthought in workers/34668.

} Second S also does not end the string, but I do not think this is a bug.

It's related to the way zsh mixes lexical analysis with alias expansion.
By the time you get to the second S, the first S has already expanded to
a double quote so the second S is quoted.

} Same thing will happen if I e.g. have unclosed `$(` or `'` in an
} alias. I think it is more correct to deal with this problem by
} errorring out when user tries to use such an alias.

There probably isn't any good way to do that.  It would require that we
treat the expansion of an alias as something to be lexed separately,
rather than treating it as having been pushed onto the input.


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

end of thread, other threads:[~2015-03-07 22:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-07 22:11 [BUG] Alias with unclosed quote leaves incorrect string in history ZyX
2015-03-07 22:48 ` 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).