about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2004-09-08 08:24:41 +0000
committerBart Schaefer <barts@users.sourceforge.net>2004-09-08 08:24:41 +0000
commite1d5c7df587c4f3d748a541f849ccca5cf799df4 (patch)
treea21b32528965d105a707d85a847331f28ab286ae /Src/exec.c
parent72fdf24448680e1e23cff86e302534b58bc2a442 (diff)
downloadzsh-e1d5c7df587c4f3d748a541f849ccca5cf799df4.tar.gz
zsh-e1d5c7df587c4f3d748a541f849ccca5cf799df4.tar.xz
zsh-e1d5c7df587c4f3d748a541f849ccca5cf799df4.zip
20325: consensus fix for "command -v" crash w/POSIXBUILTINS.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 5fd2a2e30..fb1433764 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1825,7 +1825,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		    load_module(((Builtin) hn)->optstr);
 		    hn = builtintab->getnode(builtintab, cmdarg);
 		}
-		assign = (hn->flags & BINF_MAGICEQUALS);
+		assign = (hn && (hn->flags & BINF_MAGICEQUALS));
 		break;
 	    }
 	    cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
@@ -1939,7 +1939,18 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		return;
 	    }
 
-	    if (errflag || checked ||
+	    /*
+	     * Quit looking for a command if:
+	     * - there was an error; or
+	     * - we checked the simple cases needing MAGIC_EQUAL_SUBST; or
+	     * - we know we already found a builtin (because either:
+	     *   - we loaded a builtin from a module, or
+	     *   - we have determined there are options which would
+	     *     require us to use the "command" builtin); or
+	     * - we aren't using POSIX and so BINF_COMMAND indicates a zsh
+	     *   precommand modifier is being used in place of the builtin
+	     */
+	    if (errflag || checked || is_builtin ||
 		(unset(POSIXBUILTINS) && (cflags & BINF_COMMAND)))
 		break;