Check if a command is valid

Kenny Meyer knny.myer at gmail.com
Wed Jul 14 08:58:16 EDT 2010


On Jul 13, 4:14 pm, Hans Mulder <han... at xs4all.nl> wrote:
> 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

Oh thanks, Hans! `type` seems to a good alternative. Surely it can
also get the job (better) done.



More information about the Python-list mailing list