diff options
author | Bart Schaefer <barts@users.sourceforge.net> | 2004-09-08 08:24:41 +0000 |
---|---|---|
committer | Bart Schaefer <barts@users.sourceforge.net> | 2004-09-08 08:24:41 +0000 |
commit | e1d5c7df587c4f3d748a541f849ccca5cf799df4 (patch) | |
tree | a21b32528965d105a707d85a847331f28ab286ae /Src/exec.c | |
parent | 72fdf24448680e1e23cff86e302534b58bc2a442 (diff) | |
download | zsh-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.c | 15 |
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; |