Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _expand_alias does not expand aliases that contain an "!"
On Wed, 01 Oct 2014 09:29:34 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author