Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Is "command" working right, yet?



On Tue, 11 Oct 2016 15:40:33 +0200
Martijn Dekker <martijn@xxxxxxxx> wrote:
> Another issue crept in: 'command -v' and 'command -V' now always act as
> if the -p option is given, i.e. they always search the default system
> PATH for external commands rather than the current one.

They are assuming -p is set, yes.

pws

diff --git a/Src/builtin.c b/Src/builtin.c
index a274ff7..8b8b217 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3663,7 +3663,7 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 		returnval = 1;
 	    }
 	    popheap();
-	} else if (func == BIN_COMMAND &&
+	} else if (func == BIN_COMMAND && OPT_ISSET(ops,'p') &&
 		   (hn = builtintab->getnode(builtintab, *argv))) {
 	    /*
 	     * Special case for "command -p[vV]" which needs to
@@ -3671,7 +3671,9 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 	     */
 	    builtintab->printnode(hn, printflags);
 	    informed = 1;
-	} else if ((cnam = findcmd(*argv, 1, func == BIN_COMMAND))) {
+	} else if ((cnam = findcmd(*argv, 1,
+				   func == BIN_COMMAND &&
+				   OPT_ISSET(ops,'p')))) {
 	    /* Found external command. */
 	    if (wd) {
 		printf("%s: command\n", *argv);



Messages sorted by: Reverse Date, Date, Thread, Author