From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15665 invoked by alias); 30 Aug 2014 20:31:39 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33069 Received: (qmail 22859 invoked from network); 30 Aug 2014 20:31:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140830133206.ZM13172@torch.brasslantern.com> Date: Sat, 30 Aug 2014 13:32:06 -0700 In-reply-to: Comments: In reply to Jonathan H "_expand_alias does not expand aliases that contain an "!"" (Aug 26, 9:50am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Jonathan H , zsh-workers@zsh.org Subject: Re: _expand_alias does not expand aliases that contain an "!" MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 26, 9:50am, Jonathan H wrote: } } Aliases that contain an exclamation point are not correctly expanded } by _expand_alias. You've encountered a fairly generic problem with the completion system, to wit, special characters like '!' must be quoted in some contexts, but must not be in other contexts. You'd find the same issue with an alias containing an asterisk, question mark, etc. The following makes this work more of the time in the specific case of alias expansion, but introduces what might be described as the inverse problem. That is, after the patch below, % gc\! will expand with _expand_alias, because the backslash is incorrectly removed prior to looking up the alias. There's no compstate value or the like to indicate that the original string on the line contained a backslash that shouldn't be removed. (Examining $words[CURRENT] may be a way around this, I haven't worked that out.) Incidentally: Running "compinit" binds ^Xa to _expand_alias for you. diff --git a/Completion/Base/Completer/_expand_alias b/Completion/Base/Completer/_expand_alias index 8240e41..9064ce8 100644 --- a/Completion/Base/Completer/_expand_alias +++ b/Completion/Base/Completer/_expand_alias @@ -25,6 +25,8 @@ 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;;