From patchwork Fri May 18 18:39:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10411855 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5524C6037D for ; Fri, 18 May 2018 18:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4189128707 for ; Fri, 18 May 2018 18:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36A0E28A8E; Fri, 18 May 2018 18:39:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7C7428707 for ; Fri, 18 May 2018 18:39:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751606AbeERSjx (ORCPT ); Fri, 18 May 2018 14:39:53 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:48252 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751545AbeERSjx (ORCPT ); Fri, 18 May 2018 14:39:53 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1fJkIB-0006Dp-VT for ; Sat, 19 May 2018 02:39:52 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1fJkIB-0005pd-Gm; Sat, 19 May 2018 02:39:51 +0800 Subject: [v3 PATCH 13/17] exec: Never rehash regular built-ins References: <20180518183844.zizl3xevlcm4gzsj@gondor.apana.org.au> To: DASH Mailing List Message-Id: From: Herbert Xu Date: Sat, 19 May 2018 02:39:51 +0800 Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As regular (including special) built-ins can never be overridden, we should never remove them from the hash table. Signed-off-by: Herbert Xu --- src/exec.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 {