about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Builtins/_hash1
-rw-r--r--Completion/Builtins/_vars_eq2
-rw-r--r--Doc/Zsh/builtins.yo5
-rw-r--r--Src/builtin.c11
-rw-r--r--Src/hashtable.c14
6 files changed, 32 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b2f8f800..d7434b7ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-05-15  Oliver Kiddle  <opk@zsh.org>
+
+	* 11xxx: Src/builtin.c, Src/hashtable.c, Completion/Builtins/_hash,
+	Doc/Zsh/builtins.yo, Completion/Builtins/_vars_eq: add -L opt to hash
+
 2000-05-14  Peter Stephenson  <pws@pwstephenson.fsnet.co.uk>
 
 	* Src/builtin.c: make integer builtin understand `-i base'.
diff --git a/Completion/Builtins/_hash b/Completion/Builtins/_hash
index e748028fb..de8c1887c 100644
--- a/Completion/Builtins/_hash
+++ b/Completion/Builtins/_hash
@@ -13,6 +13,7 @@ case ${words[1]} in
       '(-f -m -v)-r[empty hash table]' \
       '(-f -r)-m[treat arguments as patterns]' \
       '(-f -r -m)-v[list entires as they are added]' \
+      '(-f -r -v)-L[list in the form of calls to hash]' \
       "${common_args[@]}" \
       '(-d -f -r -m -v)*:hash:->hashval' && return 0
   ;;
diff --git a/Completion/Builtins/_vars_eq b/Completion/Builtins/_vars_eq
index e66600852..cda16307f 100644
--- a/Completion/Builtins/_vars_eq
+++ b/Completion/Builtins/_vars_eq
@@ -39,7 +39,7 @@ case ${words[1]} in
     use="Umtu"
     func=f
   ;;
-  integer) use="ghlrtux" ;;
+  integer) use="ghilrtux" ;;
   readonly) use="${use/r/}" ;;
   local) use="${use/f/}" ;&
   export) use="${${use/g/}/x/}" ;;
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 6d6b9cfbc..86128bb8d 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -452,7 +452,7 @@ an error message when an option is invalid.  The exit status is
 nonzero when there are no more options.
 )
 findex(hash)
-item(tt(hash) [ tt(-dfmrv) ] [ var(name)[tt(=)var(value)] ] ...)(
+item(tt(hash) [ tt(-Ldfmrv) ] [ var(name)[tt(=)var(value)] ] ...)(
 tt(hash) can be used to directly modify the contents of the command
 hash table, and the named directory hash table.  Normally one would
 modify these tables by modifying one's tt(PATH)
@@ -494,6 +494,9 @@ the hash table will be unchanged.
 
 The tt(-v) option causes hash table entries to be listed as they are
 added by explicit specification.  If has no effect if used with tt(-f).
+
+If the tt(-L) flag is present, then each hash table entry is printed in
+the form of a call to hash.
 )
 alias(history)(fc -l)
 findex(integer)
diff --git a/Src/builtin.c b/Src/builtin.c
index 9c5f5ed81..24b60fb30 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -68,7 +68,7 @@ static struct builtin builtins[] =
     BUILTIN("functions", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "mtuU", NULL),
     BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"),
     BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL),
-    BUILTIN("hash", BINF_MAGICEQUALS, bin_hash, 0, -1, 0, "dfmrv", NULL),
+    BUILTIN("hash", BINF_MAGICEQUALS, bin_hash, 0, -1, 0, "Ldfmrv", NULL),
 
 #ifdef ZSH_HASH_DEBUG
     BUILTIN("hashinfo", 0, bin_hashinfo, 0, 0, 0, NULL, NULL),
@@ -99,7 +99,7 @@ static struct builtin builtins[] =
     BUILTIN("r", BINF_R, bin_fc, 0, -1, BIN_FC, "nrl", NULL),
     BUILTIN("read", 0, bin_read, 0, -1, 0, "rzu0123456789pkqecnAlE", NULL),
     BUILTIN("readonly", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFLRTUZafghiltux", "r"),
-    BUILTIN("rehash", 0, bin_hash, 0, 0, 0, "dfv", "r"),
+    BUILTIN("rehash", 0, bin_hash, 0, 0, 0, "df", "r"),
     BUILTIN("return", BINF_PSPECIAL, bin_break, 0, 1, BIN_RETURN, NULL, NULL),
     BUILTIN("set", BINF_PSPECIAL, bin_set, 0, -1, 0, NULL, NULL),
     BUILTIN("setopt", 0, bin_setopt, 0, -1, BIN_SETOPT, NULL, NULL),
@@ -2461,6 +2461,7 @@ bin_hash(char *name, char **argv, char *ops, int func)
     Patprog pprog;
     Asgment asg;
     int returnval = 0;
+    int printflags = 0;
 
     if (ops['d'])
 	ht = nameddirtab;
@@ -2485,9 +2486,11 @@ bin_hash(char *name, char **argv, char *ops, int func)
 	return 0;
     }
 
+    if (ops['L']) printflags |= PRINT_LIST;
+
     /* Given no arguments, display current hash table. */
     if (!*argv) {
-	scanhashtable(ht, 1, 0, 0, ht->printnode, 0);
+	scanhashtable(ht, 1, 0, 0, ht->printnode, printflags);
 	return 0;
     }
 
@@ -2498,7 +2501,7 @@ bin_hash(char *name, char **argv, char *ops, int func)
 	    tokenize(*argv);  /* expand */
 	    if ((pprog = patcompile(*argv, PAT_STATIC, NULL))) {
 		/* display matching hash table elements */
-		scanmatchtable(ht, pprog, 0, 0, ht->printnode, 0);
+		scanmatchtable(ht, pprog, 0, 0, ht->printnode, printflags);
 	    } else {
 		untokenize(*argv);
 		zwarnnam(name, "bad pattern : %s", *argv, 0);
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 917bbc9e6..9a1010ec6 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -734,6 +734,13 @@ printcmdnamnode(HashNode hn, int printflags)
 	return;
     }
 
+    if (printflags & PRINT_LIST) {
+	printf("hash ");
+
+	if(cn->nam[0] == '-')
+	    printf("-- ");
+    }
+
     if (cn->flags & HASHED) {
 	quotedzputs(cn->nam, stdout);
 	putchar('=');
@@ -1371,6 +1378,13 @@ printnameddirnode(HashNode hn, int printflags)
 	putchar('\n');
 	return;
     }
+    
+    if (printflags & PRINT_LIST) {
+      printf("hash -d ");
+
+      if(nd->nam[0] == '-')
+	    printf("-- ");
+    }
 
     quotedzputs(nd->nam, stdout);
     putchar('=');