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

whence -f



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

The patch below puts "whence -f" back into zsh.  (It mysteriously
disappeared from beta11, which I find a bit annoying as I actually use
it.)  With the PRINT_* mechanism, this can be done very neatly.

 -zefram

      *** 1.1	1995/11/23 06:07:30
      --- Src/zsh.h	1995/11/23 18:52:29
      ***************
      *** 788,793 ****
      --- 788,794 ----
        #define PRINT_WHENCE_CSH	(1<<3)
        #define PRINT_WHENCE_VERBOSE	(1<<4)
        #define PRINT_WHENCE_SIMPLE	(1<<5)
      + #define PRINT_WHENCE_FUNCDEF	(1<<6)
        
        
        /*************************************/
      *** 1.1	1995/11/23 06:07:30
      --- Src/hashtable.h	1995/11/24 18:52:09
      ***************
      *** 312,318 ****
            {NULL, "times", 0, bin_times, 0, 0, 0, NULL, NULL},
            {NULL, "trap", 0, bin_trap, 0, -1, 0, NULL, NULL},
            {NULL, "true", 0, bin_true, 0, -1, 0, NULL, NULL},
      !     {NULL, "type", 0, bin_whence, 0, -1, 0, "amp", "v"},
            {NULL, "typeset", BINF_TYPEOPTS | BINF_MAGICEQUALS, bin_typeset, 0, -1, 0, "LRZfilrtuxm", NULL},
            {NULL, "ulimit", 0, bin_ulimit, 0, 1, 0, "HSacdflmnopstv", NULL},
            {NULL, "umask", 0, bin_umask, 0, 1, 0, NULL, NULL},
      --- 312,318 ----
            {NULL, "times", 0, bin_times, 0, 0, 0, NULL, NULL},
            {NULL, "trap", 0, bin_trap, 0, -1, 0, NULL, NULL},
            {NULL, "true", 0, bin_true, 0, -1, 0, NULL, NULL},
      !     {NULL, "type", 0, bin_whence, 0, -1, 0, "ampf", "v"},
            {NULL, "typeset", BINF_TYPEOPTS | BINF_MAGICEQUALS, bin_typeset, 0, -1, 0, "LRZfilrtuxm", NULL},
            {NULL, "ulimit", 0, bin_ulimit, 0, 1, 0, "HSacdflmnopstv", NULL},
            {NULL, "umask", 0, bin_umask, 0, 1, 0, NULL, NULL},
      ***************
      *** 324,330 ****
            {NULL, "unsetopt", BINF_PLUSOPTS, bin_setopt, 0, -1, BIN_UNSETOPT, "0123456789BCDEFGHIJKLMNOPQRSTUWXYZabefghjklmnopsuvwxy", NULL},
            {NULL, "vared", 0, bin_vared, 1, 6, 0, NULL, NULL},
            {NULL, "wait", 0, bin_fg, 0, -1, BIN_WAIT, NULL, NULL},
      !     {NULL, "whence", 0, bin_whence, 0, -1, 0, "acmpv", NULL},
            {NULL, "which", 0, bin_whence, 0, -1, 0, "amp", "c"},
            {NULL, NULL}
        };
      --- 324,330 ----
            {NULL, "unsetopt", BINF_PLUSOPTS, bin_setopt, 0, -1, BIN_UNSETOPT, "0123456789BCDEFGHIJKLMNOPQRSTUWXYZabefghjklmnopsuvwxy", NULL},
            {NULL, "vared", 0, bin_vared, 1, 6, 0, NULL, NULL},
            {NULL, "wait", 0, bin_fg, 0, -1, BIN_WAIT, NULL, NULL},
      !     {NULL, "whence", 0, bin_whence, 0, -1, 0, "acmpvf", NULL},
            {NULL, "which", 0, bin_whence, 0, -1, 0, "amp", "c"},
            {NULL, NULL}
        };
      *** 1.1	1995/11/23 06:07:30
      --- Src/hashtable.c	1995/11/24 18:47:56
      ***************
      *** 662,673 ****
            Shfunc f = (Shfunc) hn;
            char *t;
         
      !     if ((printflags & PRINT_NAMEONLY) || (printflags & PRINT_WHENCE_SIMPLE)) {
        	printf("%s\n", f->nam);
        	return;
            }
         
      !     if (printflags & PRINT_WHENCE_VERBOSE) {
        	printf("%s is a shell function\n", f->nam);
        	return;
            }
      --- 662,676 ----
            Shfunc f = (Shfunc) hn;
            char *t;
         
      !     if ((printflags & PRINT_NAMEONLY) ||
      ! 	((printflags & PRINT_WHENCE_SIMPLE) &&
      ! 	!(printflags & PRINT_WHENCE_FUNCDEF))) {
        	printf("%s\n", f->nam);
        	return;
            }
         
      !     if ((printflags & PRINT_WHENCE_VERBOSE) &&
      ! 	!(printflags & PRINT_WHENCE_FUNCDEF)) {
        	printf("%s is a shell function\n", f->nam);
        	return;
            }
      *** 1.2	1995/11/23 17:04:56
      --- Src/builtin.c	1995/11/23 18:53:43
      ***************
      *** 3113,3118 ****
      --- 3113,3120 ----
        	printflags |= PRINT_WHENCE_VERBOSE;
            else
        	printflags |= PRINT_WHENCE_SIMPLE;
      +     if(ops['f'])
      + 	printflags |= PRINT_WHENCE_FUNCDEF;
        
            /* With -m option -- treat arguments as a glob patterns */
            if (ops['m']) {
      *** 1.1	1995/11/23 06:10:27
      --- Doc/zshbuiltins.1	1995/11/24 18:54:18
      ***************
      *** 862,868 ****
        no effect when the tty is frozen. Without options it reports whether the
        terminal is frozen or not.
        .TP
      ! \fBtype\fP
        Same as \fBwhence\fP \-\fBv\fP.
        .TP
        \fBtypeset\fP [ \(+-\fBLRZfilrtuxm [\fIn\fP]] [ \fIname\fP[=\fIvalue\fP] ] ...
      --- 862,868 ----
        no effect when the tty is frozen. Without options it reports whether the
        terminal is frozen or not.
        .TP
      ! \fBtype\fP [ \-\fBfpam\fP ] \fIname\fP ...
        Same as \fBwhence\fP \-\fBv\fP.
        .TP
        \fBtypeset\fP [ \(+-\fBLRZfilrtuxm [\fIn\fP]] [ \fIname\fP[=\fIvalue\fP] ] ...
      ***************
      *** 1048,1065 ****
        of a job in the job table.
        The exit status from this command is that of the job waited for.
        .TP
      ! \fBwhence\fP [ \-\fBacpvm\fP ] \fIname\fP ...
      ! For each name, indicate how it would be interpreted if used
      ! as a command name.  The \-\fBv\fP flag produces a more verbose
      ! report.  The \-\fBp\fP flag does a path search for \fIname\fP
      ! even if it is a shell function, alias, or reserved word.
      ! The \-\fBc\fP flag prints the results in a csh-like format.
        The \-\fBa\fP flag does a search for all occurrences of \fIname\fP
        throughout the command path.
        With the \-\fBm\fP flag the arguments are taken as patterns (should be
        quoted) and the information is displayed for each command matching one
        of these patterns.
        .TP
      ! \fBwhich\fP
        Same as \fBwhence \-c\fP.
        .RE
      --- 1048,1069 ----
        of a job in the job table.
        The exit status from this command is that of the job waited for.
        .TP
      ! \fBwhence\fP [ \-\fBvcfpam\fP ] \fIname\fP ...
      ! For each name, indicate how it would be interpreted if used as a
      ! command name.  The \-\fBv\fP flag produces a more verbose report.
      ! The \-\fBc\fP flag prints the results in a csh-like format,
      ! and takes precedence over \-\fBv\fP.
      ! The \-\fBf\fP flag causes the contents of a shell function to be
      ! displayed, which would otherwise not happen unless the \-\fBc\fP
      ! flag were used.
      ! The \-\fBp\fP flag does a path search for \fIname\fP
      ! even if it is an alias, reserved word, shell function or builtin.
        The \-\fBa\fP flag does a search for all occurrences of \fIname\fP
        throughout the command path.
        With the \-\fBm\fP flag the arguments are taken as patterns (should be
        quoted) and the information is displayed for each command matching one
        of these patterns.
        .TP
      ! \fBwhich\fP [ \-\fBpam\fP ] \fIname\fP ...
        Same as \fBwhence \-c\fP.
        .RE

-----BEGIN PGP SIGNATURE-----
Version: 2.6.i

iQCVAgUBMLYXynD/+HJTpU/hAQGn2AP/a60KnzuNSsUcyfcmkO+wzi2n2hyamwEd
B3nhfuj07pDBNp1MxTfqBZagDLBinI0YmgWYWVnqUldRh1y5JceNyL7qmc+PFJe+
rwXDtus4nicAA4JjNkPmfTIaTWiBqaFWsKGMUTyfYVa2Jz6h4STC79arTMHTlkqg
4534mXLNxVU=
=cP8p
-----END PGP SIGNATURE-----



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