Debian's which hunt
Debian's which hunt
Posted Oct 29, 2021 6:24 UTC (Fri) by weberm (guest, #131630)In reply to: Debian's which hunt by marcH
Parent article: Debian's which hunt
$ which type
$ type type
type is a shell builtin
$ type -p type
$
# yes, its exit status tells me type exists, but not where
$ type ls
ls is aliased to `ls --color=auto'
# I hate that alias with a passion but sometimes forget to remove it. Not the point. It ought to tell me where the expanded alias is pulling that 'ls' in.
$ which ls
/bin/ls
$ command -v ls
alias ls='ls --color=auto'
$ command -V ls
ls is aliased to `ls --color=auto'
Nothing scratches my back just like which does.
Posted Oct 29, 2021 13:59 UTC (Fri)
by pj (subscriber, #4506)
[Link] (2 responses)
IMO, `type` seems to be the best-thought-out version of this tool, and should be made standard.
Posted Oct 29, 2021 21:15 UTC (Fri)
by weberm (guest, #131630)
[Link] (1 responses)
$ type -a ls
IMO which being an external tool actually comes in quite handy here. It has its drawbacks, but also its benefits.
Posted Oct 29, 2021 21:29 UTC (Fri)
by marcH (subscriber, #57642)
[Link]
Posted Oct 29, 2021 16:28 UTC (Fri)
by overfl0w (guest, #155055)
[Link]
So when I execute the 'vim' command, actually 'nvim' is executed.
$ which vim
So in this particular case 'which' did not return the correct path. Perhaps this is due to the fact that 'vim' is a valid command. But if I executed 'vim', it would not execute the executable returned by 'which'. I found this by accident as I hadn't heard about 'command -v' before.
Debian's which hunt
ls is aliased to `ls -F --color=auto'
ls is /bin/ls
Debian's which hunt
mksh: whence: -a: unknown option
Debian's which hunt
Debian's which hunt
alias vim='nvim' in .bashrc
/usr/bin/vim
$ command -v vim
alias vim='nvim'