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 17:39:17 +0100	[thread overview]
Message-ID: <20141001173917.295076d6@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <141001092934.ZM5952@torch.brasslantern.com>

On Wed, 01 Oct 2014 09:29:34 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Maybe we just need something along the lines of makecommaspecial() that
> can be called from hbegin() to set ISPECIAL on bangchar, and called in
> the completion code to temporarily switch it off/on.
> 
> Then inittyptab() never has to mess with examining bangchar, and the
> new makebangspecial() can be called from histcharsetfn() instead of
> doing a full inittyptab().

That certainly sounds possible, if you know where to put those calls.

Here's the other proposal, done entirely local to inittyptab(), and
untested.

I'm wondering if there might be other places in the shell that could do
with knowing if the shell started in away that allowed direct user
intervention, whatever the current state may be.

pws

diff --git a/Src/utils.c b/Src/utils.c
index 9109f66..2b57d64 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3437,11 +3437,17 @@ mod_export short int typtab[256];
 void
 inittyptab(void)
 {
+    static int typtab_flags = 0;
     int t0;
     char *s;
 
-    for (t0 = 0; t0 != 256; t0++)
-	typtab[t0] = 0;
+    if (!(typtab_flags & ZTF_INIT)) {
+	typtab_flags = ZTF_INIT;
+	if (interact && isset(SHINSTDIN))
+	    typtab_flags |= ZTF_INTERACT;
+    }
+
+    memset(typtab, 0, sizeof(typtab));
     for (t0 = 0; t0 != 32; t0++)
 	typtab[t0] = typtab[t0 + 128] = ICNTRL;
     typtab[127] = ICNTRL;
@@ -3516,7 +3522,7 @@ inittyptab(void)
 	typtab[STOUC(*s)] |= ISPECIAL;
     if (specialcomma)
 	typtab[STOUC(',')] |= ISPECIAL;
-    if (isset(BANGHIST) && bangchar && interact && isset(SHINSTDIN))
+    if (isset(BANGHIST) && bangchar && (typtab_flags & ZTF_INTERACT))
 	typtab[bangchar] |= ISPECIAL;
 }
 
diff --git a/Src/ztype.h b/Src/ztype.h
index 14f6610..126aafe 100644
--- a/Src/ztype.h
+++ b/Src/ztype.h
@@ -59,6 +59,13 @@
 #define iwsep(X) zistype(X,IWSEP)
 #define inull(X) zistype(X,INULL)
 
+/*
+ * Bit flags for typtab_flags --- preserved after
+ * shell initialisation.
+ */
+#define ZTF_INIT     (0x0001) /* One-off initialisation done */
+#define ZTF_INTERACT (0x0002) /* Shell interative and reading from stdin */
+
 #ifdef MULTIBYTE_SUPPORT
 #define WC_ZISTYPE(X,Y) wcsitype((X),(Y))
 #define WC_ISPRINT(X)	iswprint(X)


  reply	other threads:[~2014-10-01 16:39 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
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 [this message]
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=20141001173917.295076d6@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).