From owner-freebsd-current Wed Dec 15 3:25:58 1999 Delivered-To: freebsd-current@freebsd.org Received: from knight.cons.org (knight.cons.org [194.233.237.195]) by hub.freebsd.org (Postfix) with ESMTP id 968EE1534E for ; Wed, 15 Dec 1999 03:25:53 -0800 (PST) (envelope-from cracauer@knight.cons.org) Received: (from cracauer@localhost) by knight.cons.org (8.9.3/8.9.3) id MAA24042; Wed, 15 Dec 1999 12:25:47 +0100 (CET) Date: Wed, 15 Dec 1999 12:25:46 +0100 From: Martin Cracauer To: Marcel Moolenaar Cc: Martin Cracauer , current@FreeBSD.ORG Subject: Re: sh(1) broken caching [was: Re: Broken sh(1)?] Message-ID: <19991215122546.A24027@cons.org> References: <712.945183175@axl.noc.iafrica.com> <38565DEA.4487DF53@scc.nl> <19991215105728.A61202@cons.org> <38576BD2.21701740@scc.nl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=6TrnltStXW4iwmi0 X-Mailer: Mutt 0.95.1i In-Reply-To: <38576BD2.21701740@scc.nl>; from Marcel Moolenaar on Wed, Dec 15, 1999 at 11:22:10AM +0100 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii In <38576BD2.21701740@scc.nl>, Marcel Moolenaar wrote: > It seems to me that when there's a PATH= assignment you don't want to > add anything to the cache or alternatively, clear the cache after > execution of the command having a PATH= assignment. The first solution is better, but the source messes with the hashtable too directly in too many places. Appended diff does the second route. Does it fix your problems? Martin -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer/ Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536 --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=diff ? test2 ? l ? test1 ? sh.core ? builtins.c ? builtins.h ? mknodes ? nodes.h ? nodes.c ? mksyntax ? syntax.c ? syntax.h ? token.h ? y.tab.h ? y.tab.c ? arith.c ? arith_lex.c ? sh ? mkinit ? init.c ? sh.1.gz Index: Makefile =================================================================== RCS file: /home/CVS-FreeBSD/src/bin/sh/Makefile,v retrieving revision 1.30 diff -c -r1.30 Makefile *** Makefile 1999/09/08 15:40:43 1.30 --- Makefile 1999/12/15 11:24:05 *************** *** 18,24 **** LDADD+= -ll -ledit -ltermcap LFLAGS= -8 # 8-bit lex scanner for arithmetic ! CFLAGS+=-DSHELL -I. -I${.CURDIR} # for debug: # CFLAGS+= -g -DDEBUG=2 --- 18,24 ---- LDADD+= -ll -ledit -ltermcap LFLAGS= -8 # 8-bit lex scanner for arithmetic ! CFLAGS+=-DSHELL -I. -I${.CURDIR} -g -Werror # for debug: # CFLAGS+= -g -DDEBUG=2 Index: eval.c =================================================================== RCS file: /home/CVS-FreeBSD/src/bin/sh/eval.c,v retrieving revision 1.26 diff -c -r1.26 eval.c *** eval.c 1999/11/29 19:10:59 1.26 --- eval.c 1999/12/15 11:24:05 *************** *** 612,623 **** --- 612,625 ---- volatile int e; char *lastarg; int realstatus; + int do_clearcmdentry; #if __GNUC__ /* Avoid longjmp clobbering */ (void) &argv; (void) &argc; (void) &lastarg; (void) &flags; + (void) &do_clearcmdentry; #endif /* First expand the arguments. */ *************** *** 626,631 **** --- 628,634 ---- arglist.lastp = &arglist.list; varlist.lastp = &varlist.list; varflag = 1; + do_clearcmdentry = 0; oexitstatus = exitstatus; exitstatus = 0; for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) { *************** *** 688,695 **** * is present */ for (sp = varlist.list ; sp ; sp = sp->next) ! if (strncmp(sp->text, PATH, sizeof(PATH) - 1) == 0) path = sp->text + sizeof(PATH) - 1; find_command(argv[0], &cmdentry, 1, path); if (cmdentry.cmdtype == CMDUNKNOWN) { /* command not found */ --- 691,700 ---- * is present */ for (sp = varlist.list ; sp ; sp = sp->next) ! if (strncmp(sp->text, PATH, sizeof(PATH) - 1) == 0) { path = sp->text + sizeof(PATH) - 1; + do_clearcmdentry = 1; + } find_command(argv[0], &cmdentry, 1, path); if (cmdentry.cmdtype == CMDUNKNOWN) { /* command not found */ *************** *** 887,892 **** --- 892,899 ---- out: if (lastarg) setvar("_", lastarg, 0); + if (do_clearcmdentry) + clearcmdentry(0); popstackmark(&smark); } Index: exec.c =================================================================== RCS file: /home/CVS-FreeBSD/src/bin/sh/exec.c,v retrieving revision 1.13 diff -c -r1.13 exec.c *** exec.c 1999/08/27 23:15:11 1.13 --- exec.c 1999/12/15 11:24:05 *************** *** 104,110 **** STATIC void execinterp __P((char **, char **)); #endif STATIC void printentry __P((struct tblentry *, int)); - STATIC void clearcmdentry __P((int)); STATIC struct tblentry *cmdlookup __P((char *, int)); STATIC void delete_cmd_entry __P((void)); --- 104,109 ---- *************** *** 640,646 **** * PATH which has changed. */ ! STATIC void clearcmdentry(firstchange) int firstchange; { --- 639,645 ---- * PATH which has changed. */ ! void clearcmdentry(firstchange) int firstchange; { Index: exec.h =================================================================== RCS file: /home/CVS-FreeBSD/src/bin/sh/exec.h,v retrieving revision 1.8 diff -c -r1.8 exec.h *** exec.h 1999/08/27 23:15:12 1.8 --- exec.h 1999/12/15 11:24:05 *************** *** 69,71 **** --- 69,72 ---- void defun __P((char *, union node *)); int unsetfunc __P((char *)); int typecmd __P((int, char **)); + void clearcmdentry __P((int)); --6TrnltStXW4iwmi0-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message