From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: _expand_alias does not expand aliases that contain an "!"
Date: Sun, 14 Sep 2014 11:30:28 -0700 [thread overview]
Message-ID: <140914113029.ZM31296@torch.brasslantern.com> (raw)
In-Reply-To: <140831135017.ZM739@torch.brasslantern.com>
On Aug 31, 1:50pm, Bart Schaefer wrote:
} Subject: Re: _expand_alias does not expand aliases that contain an "!"
}
} On Aug 30, 7:58pm, Jonathan H wrote:
} }
} } Oddly enough, for me _expand_alias works for all characters in
} } [*#?@:+-^%$.,]. the only character that didn't work and wasn't already
} } meaningful to the shell was the exclamation point.
}
} Hmm. Indeed, something is treating "!" as additionally special. The
} interesting part is that it does not always treat the first character of
} the $HISTCHARS variable as special, nor does it treat ! as special when
} it is not the first character of $HISTCHARS.
}
} Or (more likely) internally somewhere is explicitly un-quoting file
} expansion characters but is not doing so for history characters. This
} could probably be fixed but might take a while to trace down.
What this boils down to is that get_comp_string() calls the lexer to
parse the word to be completed. Metacharacters like '*' and '?' get
tokenized by the lexer, but the history character does not.
Eventually callcompfunc() invokes multiquote() on the lexed word, which
calls quotestring(), which does not re-quote the tokenized characters
but does quote the history characters. (compcore.c:706)
callcompfunc() then calls untokenize() and we end up with backslashes
in front of history characters but not in front of pattern characters.
I think that means the fix is as easy as the patch below; this doesn't
seem to break history expansion, and I can't think of any other reason
we'd want history enabled when performing word completion.
The first hunk of the patch backs out the hack in 33069.
There's a remaining, probably autoloading-related, weirdness, which is
that _expand_alias doesn't work the first time you try it unless the
completion system has already been invoked some other way (including
by having tried _expand_alias at least once already). Tracing with
_complete_debug shows that the first time through, a backslash is
being inserted before '!' even though NO_banghist is in effect; but
on the second and later attempts, there's no backslash. Puzzling.
diff --git a/Completion/Base/Completer/_expand_alias b/Completion/Base/Completer/_expand_alias
index 9064ce8..8240e41 100644
--- a/Completion/Base/Completer/_expand_alias
+++ b/Completion/Base/Completer/_expand_alias
@@ -25,8 +25,6 @@ else
pre=(_main_complete - aliases)
fi
-[[ "$compstate[quoting]" = (single|double) ]] || word="${(Q)word}"
-
zstyle -s ":completion:${curcontext}:" regular tmp || tmp=yes
case $tmp in
always) sel=r;;
diff --git a/Completion/compinit b/Completion/compinit
index f9d2c57..dc84637 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -138,6 +138,7 @@ _comp_options=(
unset
NO_allexport
NO_aliases
+ NO_banghist
NO_cshnullglob
NO_cshjunkiequotes
NO_errexit
next prev parent reply other threads:[~2014-09-14 18:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 16:50 Jonathan H
2014-08-30 20:32 ` Bart Schaefer
2014-08-31 2:58 ` Jonathan H
2014-08-31 20:50 ` Bart Schaefer
2014-09-14 18:30 ` Bart Schaefer [this message]
2014-09-14 20:55 ` Bart Schaefer
2014-10-01 14:03 ` Peter Stephenson
2014-10-01 14:06 ` Peter Stephenson
2014-10-01 14:15 ` Peter Stephenson
2014-10-01 16:29 ` Bart Schaefer
2014-10-01 16:39 ` Peter Stephenson
2014-10-02 1:11 ` Bart Schaefer
2014-10-02 5:20 ` Bart Schaefer
2014-09-23 5:59 ` Jonathan H
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=140914113029.ZM31296@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).