Andreas Metzler wrote: > Thomas Hood <[EMAIL PROTECTED]> wrote: > [command -v] > > It is not even useful as a which(1) replacement. Whereas "which" > > prints the pathname of the first executable file on the PATH, > > "command -v" prints the pathname of the first executable file on the > > PATH _or_ the pathname of the first non-executable file on the PATH. > > s/_or_/or - if there is matching executable at all in PATH -/
Yes, my statement wasn't worded very well. "command -v" prints the pathname of the first executable file on the PATH that matches its argument, if there is such a file; otherwise it prints the pathname of the first non-executable file on the PATH that matches its argument, if there is such a file; otherwise it prints nothing (or, in bash's case, it prints an error message on stderr). > FWIW I am using command -v in one of my maintainerscripts, as I needed > to check whether $command which (currently) is an alias of shell- > function exists: That is indeed the shortcoming of which(1): it can't "see" shell functions; whereas the "command" builtin can. -- Thomas Hood -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]