Subject: Re: bin/20185: recent change broke shell function replacement of builtins
To: None <dovich@tiac.net, netbsd-bugs@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 02/03/2003 21:47:24
On Mon, Feb 03, 2003 at 09:24:23PM +0000, David Laight wrote:
> > Shell functions which wrap builtins work at most once.
> > Once the wrapped builtin is invoked, the shell function is disabled.
>
> The following patch should fix it, although is slightly brutal.
> It stops builtins found by 'command xxx' from being hashed.
This is a better patch, just stop the function being overwritten.
(I've also notices that posix requires that hash not report builtins.)
David
Index: exec.c
===================================================================
RCS file: /cvsroot/src/bin/sh/exec.c,v
retrieving revision 1.35
diff -u -r1.35 exec.c
--- exec.c 2003/01/22 20:36:04 1.35
+++ exec.c 2003/02/03 21:40:45
@@ -352,7 +352,9 @@
if (*argptr == NULL) {
for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
- printentry(cmdp, verbose);
+ if (cmdp->cmdtype == CMDNORMAL ||
+ cmdp->cmdtype == CMDFUNCTION)
+ printentry(cmdp, verbose);
}
}
return 0;
@@ -597,6 +599,9 @@
cmdp = &loc_cmd;
else
cmdp = cmdlookup(name, 1);
+ if (cmdp->cmdtype == CMDFUNCTION)
+ /* DO_NOFUNC must have been set */
+ cmdp = &loc_cmd;
cmdp->cmdtype = CMDBUILTIN;
cmdp->param.bltin = bltin;
INTON;
--
David Laight: david@l8s.co.uk