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

querying the emulation mode



-----BEGIN PGP SIGNED MESSAGE-----

The patch below makes the emulate builtin display the current emulation
mode if it is invoked with no arguments.  It also adds use of this
feature to the reporter script.

I think this is necessary, as the emulation is currently an important
bit of state that can't be queried.  The alternative to this mechanism
is to add another special parameter for [sg]etting the emulation, but
that would rather amusingly have to be disabled in sh/ksh mode.

 -zefram

      Index: Doc/zshbuiltins.man
      ===================================================================
      RCS file: /home/zefram/usr/cvsroot/zsh/Doc/zshbuiltins.man,v
      retrieving revision 1.7
      diff -c -r1.7 zshbuiltins.man
      *** zshbuiltins.man	1996/07/16 14:26:41	1.7
      --- zshbuiltins.man	1996/07/16 16:47:26
      ***************
      *** 317,322 ****
      --- 317,323 ----
        If the argument is not one of the shells listed above,
        .B zsh
        will be used as a default.
      + If no argument is given, the current emulation mode is printed.
        .TP
        \fBenable\fP [ \-\fBafmr\fP ] \fIarg\fP ...
        Enable the hash table element named \fIarg\fP, presumably disabled
      Index: Src/builtin.c
      ===================================================================
      RCS file: /home/zefram/usr/cvsroot/zsh/Src/builtin.c,v
      retrieving revision 1.23
      diff -c -r1.23 builtin.c
      *** builtin.c	1996/07/16 16:35:52	1.23
      --- builtin.c	1996/07/16 16:42:55
      ***************
      *** 4677,4683 ****
        int
        bin_emulate(char *nam, char **argv, char *ops, int func)
        {
      !     emulate(*argv, 0);
            return 0;
        }
        
      --- 4677,4689 ----
        int
        bin_emulate(char *nam, char **argv, char *ops, int func)
        {
      !     /* The order of values in this array must match the *
      !      * order of the EMULATE_* constants in zsh.h.       */
      !     char const *emulations[]={"csh", "ksh", "sh", "zsh"};
      !     if(*argv)
      ! 	emulate(*argv, 0);
      !     else
      ! 	printf("%s\n", emulations[emulation]);
            return 0;
        }
        
      Index: Src/hashtable.h
      ===================================================================
      RCS file: /home/zefram/usr/cvsroot/zsh/Src/hashtable.h,v
      retrieving revision 1.9
      diff -c -r1.9 hashtable.h
      *** hashtable.h	1996/07/16 14:26:53	1.9
      --- hashtable.h	1996/07/16 16:43:43
      ***************
      *** 252,258 ****
            {NULL, "disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL},
            {NULL, "echo", BINF_PRINTOPTS | BINF_ECHOPTS, bin_print, 0, -1, BIN_ECHO, "neE", "-"},
            {NULL, "echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL},
      !     {NULL, "emulate", 0, bin_emulate, 1, 1, 0, NULL, NULL},
            {NULL, "enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL},
            {NULL, "eval", 0, bin_eval, 0, -1, BIN_EVAL, NULL, NULL},
            {NULL, "exit", 0, bin_break, 0, 1, BIN_EXIT, NULL, NULL},
      --- 252,258 ----
            {NULL, "disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL},
            {NULL, "echo", BINF_PRINTOPTS | BINF_ECHOPTS, bin_print, 0, -1, BIN_ECHO, "neE", "-"},
            {NULL, "echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL},
      !     {NULL, "emulate", 0, bin_emulate, 0, 1, 0, NULL, NULL},
            {NULL, "enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL},
            {NULL, "eval", 0, bin_eval, 0, -1, BIN_EVAL, NULL, NULL},
            {NULL, "exit", 0, bin_break, 0, 1, BIN_EXIT, NULL, NULL},
      Index: Util/reporter
      ===================================================================
      RCS file: /home/zefram/usr/cvsroot/zsh/Util/reporter,v
      retrieving revision 1.1.1.6
      diff -c -r1.1.1.6 reporter
      *** reporter	1996/05/23 10:57:12	1.1.1.6
      --- reporter	1996/07/16 16:57:39
      ***************
      *** 28,33 ****
      --- 28,34 ----
        #	"aliases"	prints only aliases.
        #	"bindings"	prints only "bindkey" commands.
        #	"completion"	prints only "compctl" commands.
      + #	"emulation"	prints the emulation mode
        #	"functions"	prints "autoload" commands or actual functions.
        #	"limits"	prints "limit" commands for things like cputime, etc.
        #	"options"	prints "setopt" commands.
      ***************
      *** 98,103 ****
      --- 99,105 ----
        		ali*)	reporter_do_aliases=yes; reporter_do_all=no ;;
        		b*)	reporter_do_bindings=yes; reporter_do_all=no ;;
        		c*)	reporter_do_compctl=yes; reporter_do_all=no ;;
      + 		e*)	reporter_do_emulation=yes; reporter_do_all=no ;;
        		f*)	reporter_do_fun=yes; reporter_do_all=no ;;
        		l*)	reporter_do_lim=yes; reporter_do_all=no ;;
        		o*)	reporter_do_setopt=yes; reporter_do_all=no ;;
      ***************
      *** 378,383 ****
      --- 380,398 ----
        fi
        
        #
      + #	EMULATION
      + #
      + 
      + if test "$reporter_do_all" = "yes" -o "$reporter_do_emulation" = "yes"
      + then
      + 	echo
      + 	echo '# Emulation.'
      + 	echo
      + 
      + 	echo "emulate $(emulate)"
      + fi
      + 
      + #
        #	SETOPT
        #
        #	We exclude interactive because "setopt interactive" has no effect.
      ***************
      *** 415,420 ****
      --- 430,436 ----
        unset reporter_do_aliases
        unset reporter_do_bindings
        unset reporter_do_compctl
      + unset reporter_do_emulation
        unset reporter_do_fun
        unset reporter_do_lim
        unset reporter_do_setopt

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMevLWHD/+HJTpU/hAQH3XAP/VgsfVJe+8VN0BFpAKTT3NXPloumJPAL6
a9HLxSO7D52BMn6Bqo7/uc0jZJGVtnsQCQCTC7TdB+OocIFnaTZJIZuyUrvLmfOb
g+8pCoe4nBT9aW6PLmuGnSHI4XqvHfzN+qesxcuYb/K/7paA9D7iXq0OtgXj7gyb
tBoe1Sctxcs=
=OPbw
-----END PGP SIGNATURE-----




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