summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-05-19 02:39:51 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2018-05-28 17:12:23 +0800
commit59e62c9a3c67eef2bf9dc86e5bf0b2c88d6e8571 (patch)
tree0193342808ab29ed3785ad8f9363cc9a72b59e31 /src
parentexec: Stricter pathopt parsing (diff)
downloaddash-59e62c9a3c67eef2bf9dc86e5bf0b2c88d6e8571.tar.gz
dash-59e62c9a3c67eef2bf9dc86e5bf0b2c88d6e8571.zip
exec: Never rehash regular built-ins
As regular (including special) built-ins can never be overridden,
we should never remove them from the hash table.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/exec.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/exec.c b/src/exec.c
index 8948754..6c0a64f 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -287,9 +287,11 @@ hashcmd(int argc, char **argv)
 	}
 	c = 0;
 	while ((name = *argptr) != NULL) {
-		if ((cmdp = cmdlookup(name, 0)) != NULL
-		 && (cmdp->cmdtype == CMDNORMAL
-		     || (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
+		if ((cmdp = cmdlookup(name, 0)) &&
+		    (cmdp->cmdtype == CMDNORMAL ||
+		     (cmdp->cmdtype == CMDBUILTIN &&
+		      !(cmdp->param.cmd->flags & BUILTIN_REGULAR) &&
+		      builtinloc > 0)))
 			delete_cmd_entry();
 		find_command(name, &entry, DO_ERR, pathval());
 		if (entry.cmdtype == CMDUNKNOWN)
@@ -377,7 +379,8 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
 			bit = DO_NOFUNC;
 			break;
 		case CMDBUILTIN:
-			bit = DO_ALTBLTIN;
+			bit = cmdp->param.cmd->flags & BUILTIN_REGULAR ?
+			      0 : DO_ALTBLTIN;
 			break;
 		}
 		if (act & bit) {
@@ -601,7 +604,9 @@ clearcmdentry(void)
 		pp = tblp;
 		while ((cmdp = *pp) != NULL) {
 			if (cmdp->cmdtype == CMDNORMAL ||
-			    (cmdp->cmdtype == CMDBUILTIN && builtinloc > 0)) {
+			    (cmdp->cmdtype == CMDBUILTIN &&
+			     !(cmdp->param.cmd->flags & BUILTIN_REGULAR) &&
+			     builtinloc > 0)) {
 				*pp = cmdp->next;
 				ckfree(cmdp);
 			} else {