Zsh Mailing List Archive
Messages sorted by:
Re: segfault in completion when using alias with \ as last character
On Aug 1, 10:49pm, Bart Schaefer wrote:
} Subject: Re: segfault in completion when using alias with \ as last charac
} The upshot seems to be that the trailing backslash in the expanded
} alias causes the space after "foo" on the command line to be consumed
} as part of the command word.
I've tried a couple of different things and I think we need to take a
step back and figure out what OUGHT to be completed in this case.
I can stop it from segfaulting by tweaking we/wb in gotword(), but then
it completes strange inconsistent things depending on the comparative
lengths of the left=right sides of the alias. And things get even
stranger if you have further aliases that remove the backslash again
(e.g. alias 'bar\ '=something).
One note: In the case of the alias, gotword() is actually called more
than once, the first time after parsing 'foo' and the second after
parsing 'bar\'. For completion purposes, the "correct" values are the
ones from the first call, because they describe the raw command line.
I think lexflags = 0 in gotword is supposed to have something to do
with this, but that doesn't kick in until the second call after the
damage has already been done. (Also it seems like overkill, why are we
clearing ALL the flags here?)
Aside: Why is gotword() marked mod_export? Nothing calls it except
exalias() right there in lex.c.
Back to "what ought we do?" ...
The effect of the alias is going to be to turn the first two words on
the command line into a different single word which is then going to
be treated as the command name. The only correct completion would be
the tail end of words that form a command after the alias expands,
that is, if "/usr/bin/bar none" were a command, then
% foo <TAB>
% foo none
is the only correct thing to complete, but to get that seemingly un-
quoted space to become part of the word "foo " is a nightmare (and an
edge case that doesn't seem worth a lot of effort).
Maybe we just should have stuck with having aliases always expand like
history does, way back when.
Messages sorted by: