zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: _expand_alias does not expand aliases that contain an "!"
Date: Wed, 01 Oct 2014 15:03:24 +0100	[thread overview]
Message-ID: <20141001150324.1cdad6c9@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <140914135552.ZM31608@torch.brasslantern.com>

On Sun, 14 Sep 2014 13:55:52 -0700
Bart Schaefer <schaefer@brasslantern.com> 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


  reply	other threads:[~2014-10-01 14:03 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
2014-09-14 20:55         ` Bart Schaefer
2014-10-01 14:03           ` Peter Stephenson [this message]
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=20141001150324.1cdad6c9@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.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).