From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26334 invoked by alias); 23 Sep 2014 05:59:54 -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: 33220 Received: (qmail 26613 invoked from network); 23 Sep 2014 05:59:41 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=6Cs4JqrIcyI9B9eoOn9kZAs2Jo9EiNsl2tbmKYnrt8I=; b=MC3pGc/Zym5SQz00q/whPUPjWsXU1NpdFNh6H2dZY3k5swlE+eEccatzHprTDDQgVA PY0bWRONegJYmmSRHLoKybOUpiHw85eOM4y+UQWUeq3GGh84KFMKTVRTGfj85px1kJ5q WMBgKrgTYXu57DHJZhHDmB+dlOGBzTp4N76vgfEszV/soKX0haYYGGMYa6GEQ5QTQKFN ndDKBlb7Lqy/SL3yCaVsLbJGYoxYRp/hymbtq0QgO6JBsqevN6hUmJaG1J4JUVbxNh0p RxOsm1yfbOKWIN43VsTzUfadT43n7aDNMT2bH+k9NzOnCorh0/8pLJB6pbONqdaCSaBE y2Aw== X-Received: by 10.140.84.231 with SMTP id l94mr16312907qgd.84.1411451978560; Mon, 22 Sep 2014 22:59:38 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <140914113029.ZM31296@torch.brasslantern.com> References: <140830133206.ZM13172@torch.brasslantern.com> <140831135017.ZM739@torch.brasslantern.com> <140914113029.ZM31296@torch.brasslantern.com> From: Jonathan H Date: Mon, 22 Sep 2014 22:59:08 -0700 Message-ID: Subject: Re: _expand_alias does not expand aliases that contain an "!" To: Bart Schaefer Cc: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 Thank you! Unfortunately, I'm not much use when it comes to the zsh core. But it sounds like you've already done some fixes. Thank you for your time. (If anything else change I'd be eager to know) ~PythonNut On Sun, Sep 14, 2014 at 11:30 AM, Bart Schaefer wrote: > 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