summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2013-02-13 15:05:01 +0100
committerMikael Magnusson <mikachu@gmail.com>2015-03-27 01:27:55 +0100
commit225140c2aa029c9f19615c5894c4813a88afca49 (patch)
tree01eb5804dcd7d00a50fdedf941e42dcfbbdaec29
parent7aa9e4be0f4c7e5045b85f639c29149b920b7bee (diff)
unposted: add -F to whence, show function definition file
-rw-r--r--Src/builtin.c6
-rw-r--r--Src/hashtable.c9
-rw-r--r--Src/zsh.h1
3 files changed, 14 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 12910be0c..d20eb8341 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -119,7 +119,7 @@ static struct builtin builtins[] =
BUILTIN("times", BINF_PSPECIAL, bin_times, 0, 0, 0, NULL, NULL),
BUILTIN("trap", BINF_PSPECIAL | BINF_HANDLES_OPTS, bin_trap, 0, -1, 0, NULL, NULL),
BUILTIN("true", 0, bin_true, 0, -1, 0, NULL, NULL),
- BUILTIN("type", 0, bin_whence, 0, -1, 0, "ampfsSw", "v"),
+ BUILTIN("type", 0, bin_whence, 0, -1, 0, "ampfFsSw", "v"),
BUILTIN("typeset", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%klprtuxmz", NULL),
BUILTIN("umask", 0, bin_umask, 0, 1, 0, "S", NULL),
BUILTIN("unalias", 0, bin_unhash, 1, -1, 0, "ms", "a"),
@@ -128,7 +128,7 @@ static struct builtin builtins[] =
BUILTIN("unset", BINF_PSPECIAL, bin_unset, 1, -1, 0, "fmv", NULL),
BUILTIN("unsetopt", 0, bin_setopt, 0, -1, BIN_UNSETOPT, NULL, NULL),
BUILTIN("wait", 0, bin_fg, 0, -1, BIN_WAIT, NULL, NULL),
- BUILTIN("whence", 0, bin_whence, 0, -1, 0, "acmpvfsSw", NULL),
+ BUILTIN("whence", 0, bin_whence, 0, -1, 0, "acmpvfFsSw", NULL),
BUILTIN("where", 0, bin_whence, 0, -1, 0, "pmsSw", "ca"),
BUILTIN("which", 0, bin_whence, 0, -1, 0, "ampsSw", "c"),
BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "AFRILP:abcfdilmpue", NULL),
@@ -3199,6 +3199,8 @@ bin_whence(char *nam, char **argv, Options ops, int func)
printflags |= PRINT_WHENCE_SIMPLE;
if (OPT_ISSET(ops,'f'))
printflags |= PRINT_WHENCE_FUNCDEF;
+ if (OPT_ISSET(ops,'F'))
+ printflags |= PRINT_WHENCE_FUNCFROM;
if (func == BIN_COMMAND)
if (OPT_ISSET(ops,'V')) {
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 7a430629d..67b8fd6f9 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -911,6 +911,15 @@ printshfuncnode(HashNode hn, int printflags)
Shfunc f = (Shfunc) hn;
char *t = 0;
+ if (printflags & PRINT_WHENCE_FUNCFROM) {
+ printf("from: ");
+ if(f->filename)
+ zputs(f->filename, stdout);
+ else
+ printf("(unknown)");
+ putchar('\n');
+ }
+
if ((printflags & PRINT_NAMEONLY) ||
((printflags & PRINT_WHENCE_SIMPLE) &&
!(printflags & PRINT_WHENCE_FUNCDEF))) {
diff --git a/Src/zsh.h b/Src/zsh.h
index 6b3cb977d..9c6f80363 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1883,6 +1883,7 @@ typedef groupset *Groupset;
#define PRINT_WHENCE_SIMPLE (1<<8)
#define PRINT_WHENCE_FUNCDEF (1<<9)
#define PRINT_WHENCE_WORD (1<<10)
+#define PRINT_WHENCE_FUNCFROM (1<<11)
/* Return values from loop() */