From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from math.gatech.edu (euclid.skiles.gatech.edu [130.207.146.50]) by werple.net.au (8.7/8.7.1) with SMTP id GAA08528 for ; Sat, 25 Nov 1995 06:29:35 +1100 (EST) Received: by math.gatech.edu (5.x/SMI-SVR4) id AA04704; Fri, 24 Nov 1995 14:07:28 -0500 Resent-Date: Fri, 24 Nov 1995 19:07:50 +0000 (GMT) Old-Return-Path: From: Zefram Message-Id: <12687.199511241907@stone.dcs.warwick.ac.uk> Subject: whence -f To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Fri, 24 Nov 1995 19:07:50 +0000 (GMT) X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]6643.98 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-Id: <"HMTub3.0.N91.lVXjm"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/644 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----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-----