From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14277 invoked from network); 15 May 2000 07:12:25 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 May 2000 07:12:25 -0000 Received: (qmail 7776 invoked by alias); 15 May 2000 07:11:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11358 Received: (qmail 7746 invoked from network); 15 May 2000 07:11:43 -0000 Sender: opk Message-ID: <391F3590.E939CAE1@u.genie.co.uk> Date: Mon, 15 May 2000 00:24:00 +0100 From: Oliver Kiddle X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.15 i586) X-Accept-Language: en MIME-Version: 1.0 To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: use of _arguments for hash References: <200005121433.QAA00724@beta.informatik.hu-berlin.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sven Wischnowsky wrote: > Oliver Kiddle wrote: > > Why does rehash accept the -v option when as far as I can > > tell, it can never do anything? Would it be useful to add a -L option > > to hash similar to alias -L? > > Seems reasonable, but personally I don't care much... I don't really care a great deal either and I probably would have never noticed if I hadn't been doing the completion function. Anyway, it seemed like a simple enough change so I've done it. I've also changed _vars_eq to handle Peter's change for integer -i. It's too late too look at this in any more detail but I've just found that I get a seg fault when I do this: diff .c ^cursor here. Oliver Index: Completion/Builtins/_hash =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_hash,v retrieving revision 1.4 diff -u -r1.4 _hash --- Completion/Builtins/_hash 2000/05/12 13:16:52 1.4 +++ Completion/Builtins/_hash 2000/05/15 00:23:24 @@ -13,6 +13,7 @@ '(-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 ;; Index: Completion/Builtins/_vars_eq =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_vars_eq,v retrieving revision 1.5 diff -u -r1.5 _vars_eq --- Completion/Builtins/_vars_eq 2000/05/12 13:16:52 1.5 +++ Completion/Builtins/_vars_eq 2000/05/15 00:23:24 @@ -39,7 +39,7 @@ use="Umtu" func=f ;; - integer) use="ghlrtux" ;; + integer) use="ghilrtux" ;; readonly) use="${use/r/}" ;; local) use="${use/f/}" ;& export) use="${${use/g/}/x/}" ;; Index: Doc/Zsh/builtins.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v retrieving revision 1.8 diff -u -r1.8 builtins.yo --- Doc/Zsh/builtins.yo 2000/05/14 22:08:41 1.8 +++ Doc/Zsh/builtins.yo 2000/05/15 00:23:32 @@ -452,7 +452,7 @@ 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 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) Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.16 diff -u -r1.16 builtin.c --- Src/builtin.c 2000/05/14 22:08:42 1.16 +++ Src/builtin.c 2000/05/15 00:23:44 @@ -68,7 +68,7 @@ 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 @@ 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 @@ Patprog pprog; Asgment asg; int returnval = 0; + int printflags = 0; if (ops['d']) ht = nameddirtab; @@ -2485,9 +2486,11 @@ 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 @@ 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); Index: Src/hashtable.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v retrieving revision 1.6 diff -u -r1.6 hashtable.c --- Src/hashtable.c 2000/04/30 17:09:08 1.6 +++ Src/hashtable.c 2000/05/15 00:23:48 @@ -734,6 +734,13 @@ return; } + if (printflags & PRINT_LIST) { + printf("hash "); + + if(cn->nam[0] == '-') + printf("-- "); + } + if (cn->flags & HASHED) { quotedzputs(cn->nam, stdout); putchar('='); @@ -1370,6 +1377,13 @@ zputs(nd->nam, stdout); putchar('\n'); return; + } + + if (printflags & PRINT_LIST) { + printf("hash -d "); + + if(nd->nam[0] == '-') + printf("-- "); } quotedzputs(nd->nam, stdout);