Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _expand_alias does not expand aliases that contain an "!"



On Sun, 14 Sep 2014 13:55:52 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> What's happening is that the ISPECIAL bit is never restored in the event
> that BANGHIST is toggled off and back on again "in the background"; it
> is only set if BANGHIST is toggled interactively, e.g., from an init
> file or the command line.
> 
> Src/utils.c:
>    3519     if (isset(BANGHIST) && bangchar && interact && isset(SHINSTDIN))
>    3520         typtab[bangchar] |= ISPECIAL;
> 
> There's something wrong with that test.  Either we don't need the ISPECIAL
> bit on the first character of histchars -- history still seems to work as
> long as the BANGHIST option is set, even if '!' is not marked special, but
> there may be cases I didn't try -- or we need to fix the conditions in
> which ISPECIAL-ness is restored.

I haven't thought of a crushingly sane and rational course of action
here [so no change there, then].

I've a vague feeling the specialness is only applicable to tests for
whether the ! is special "in some general sense", e.g. needs quoting
when it gets inserted onto the command line, and that bangchar itself is
always used directly in the history code (which is what your results
suggest).  So if we can do that test other ways we wouldn't need this.
But I'm a bit worried there's some non-completion quoting code that
might need this, e.g. quotestring() with QT_BACKSLASH.  In the case of !
there's perhaps no great problem in quoting it anyway, but it might be
different if the character got changed (another feature I hate).

On possible fix would be to add a separate variable to remember the
original ISPECIAL bit for bangchar (which would be transferable if
bangchar became a different character) and restore it at this point if
this isn't the original setting up of typtab --- which is where the last
two tests really make sense.  So only the first two tests would remain
here in all cases.  That may seem a bit baroque given no other character
needs this, but it makes the code relatively insensitive to context.

pws



Messages sorted by: Reverse Date, Date, Thread, Author