Check if a command is valid

Hans Mulder hansmu at xs4all.nl
Tue Jul 13 16:14:27 EDT 2010


Chris Rebert wrote:

> `where` seems to be a zsh built-in:
> $ # I'm in UR bash
> $ nonexistent
> -bash: nonexistent: command not found
> $ where bash
> -bash: where: command not found
> 
> And not everyone has zsh installed, so...
> I don't see why one shouldn't use the standard `which` *nix command instead.

Because `which` ia a C shell script.  It reads your .cshrc, to see which
aliases would be defined if you were to use the C shell, but it doesn't
look at your .bashrc.

You're probably better off using `type`: it knows about built-ins and
shell functions and that sort of stuff:

$ which type
/usr/bin/type
$ type type
type is a shell builtin
$

Guess which answer is more relevant to you .....

HTH,

-- HansM



More information about the Python-list mailing list