about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 710402f86..7a6ed15e4 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1692,14 +1692,16 @@ execcmd(Cmd cmd, int input, int output, int how, int last1)
 	if (!hn) {
 	    /* Resolve external commands */
 	    char *cmdarg = (char *) peekfirst(args);
+	    int dohashcmd = isset(HASHCMDS);
 
 	    hn = cmdnamtab->getnode(cmdnamtab, cmdarg);
 	    if (hn && trycd && !isreallycom((Cmdnam)hn)) {
 		cmdnamtab->removenode(cmdnamtab, cmdarg);
 		cmdnamtab->freenode(hn);
 		hn = NULL;
+		dohashcmd = 1;
 	    }
-	    if (!hn && isset(HASHCMDS) && strcmp(cmdarg, "..")) {
+	    if (!hn && dohashcmd && strcmp(cmdarg, "..")) {
 		for (s = cmdarg; *s && *s != '/'; s++);
 		if (!*s)
 		    hn = (HashNode) hashcmd(cmdarg, pathchecked);