From c7d8b0dfb8ae9670e2bc11ecf563200069a3a12f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 11 Feb 2009 20:42:15 +0000 Subject: 26546, 26556: sticky emulation for functions defined in emulate ... -c ... environments, plus documentation --- Src/options.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'Src/options.c') diff --git a/Src/options.c b/Src/options.c index 3c7f88048..f852ec830 100644 --- a/Src/options.c +++ b/Src/options.c @@ -35,6 +35,11 @@ /**/ mod_export int emulation; +/* current sticky emulation: 0 means none */ + +/**/ +mod_export int sticky_emulation; + /* the options; e.g. if opts[SHGLOB] != 0, SH_GLOB is turned on */ /**/ @@ -58,9 +63,12 @@ mod_export HashTable optiontab; #define OPT_NONBOURNE (OPT_ALL & ~OPT_BOURNE) #define OPT_NONZSH (OPT_ALL & ~OPT_ZSH) -#define OPT_EMULATE (1<<5) /* option is relevant to emulation */ -#define OPT_SPECIAL (1<<6) /* option should never be set by emulate() */ -#define OPT_ALIAS (1<<7) /* option is an alias to an other option */ +/* option is relevant to emulation */ +#define OPT_EMULATE (EMULATE_UNUSED) +/* option should never be set by emulate() */ +#define OPT_SPECIAL (EMULATE_UNUSED<<1) +/* option is an alias to an other option */ +#define OPT_ALIAS (EMULATE_UNUSED<<2) #define defset(X) (!!((X)->node.flags & emulation)) @@ -475,6 +483,14 @@ setemulate(HashNode hn, int fully) opts[on->optno] = defset(on); } +/**/ +void +installemulation(void) +{ + scanhashtable(optiontab, 0, 0, 0, setemulate, + !!(emulation & EMULATE_FULLY)); +} + /**/ void emulate(const char *zsh_name, int fully) @@ -494,7 +510,9 @@ emulate(const char *zsh_name, int fully) else emulation = EMULATE_ZSH; - scanhashtable(optiontab, 0, 0, 0, setemulate, fully); + if (fully) + emulation |= EMULATE_FULLY; + installemulation(); } /* setopt, unsetopt */ -- cgit 1.4.1