[linux-l] Re: shell: internal "which" checks aliases and functions

Steffen Dettmer steffen at dett.de
Do Dez 14 16:52:27 CET 2006


* Sven Guckes wrote on Tue, Dec 12, 2006 at 15:00 +0100:
> erstmal die version anzeigen:
> 
>   bash-3.1> echo $BASH_VERSION
2.05b.0(1)-release

> welche which benutzen wir denn?
> 
>   bash-3.1> which which

steffen at link:~> which which
steffen at link:~> 

lol

steffen at link:~> which --version
-bash: type: --: invalid option
type: usage: type [-afptP] name [name ...]

steffen at link:~> /usr/bin/which --version
GNU which v2.13, Copyright (C) 1999, 2000 Carlo Wood.
[...]

secret-built-in-which?!

> alias definieren und testen:

steffen at link:~> foo
bar

> alias funktioniert also.

steffen at link:~> which foo
steffen at link:~> which -a foo
steffen at link:~>
steffen at link:~> /usr/bin/which -a foo
/usr/bin/which: no foo in
(/usr/local/bin:/usr/bin:...more...)

> hmm... was fehlt mir denn da?

steffen at link:~> type which
which is aliased to `type -p'

steffen at link:~> type /usr/bin/which
/usr/bin/which is /usr/bin/which

steffen at link:~> type -a which
which is aliased to `type -p'
which is /usr/bin/which

man bash /type

              [...] If the
              -p option is used, type either returns  the  name  of  the
              disk file that would be executed if name were specified as
              a command name, or nothing if ``type -t name''  would  not
              return  file [...]
              [...] If  the
              -a option is used, type prints all of the places that con­
              tain an executable named name.

iss schon bissel komisch; which is also so gedreht, dass es eben gerade
keine Aliase auflöst. Vermutlich ein Feature für Scripts (da ist das
vermutlich i.d.R. besser so, man kann so ggf. Kommandos "emulieren" oder
so).

Statt whence also "type -a" in bash, scheint dann das zu sein, was man
interaktiv möchte, oder?

oki,

Steffen

-- 
Dieses Schreiben wurde maschinell erstellt,
es trägt daher weder Unterschrift noch Siegel.





Mehr Informationen über die Mailingliste linux-l