Re:How does `cd` work?
by jwilk on Thursday March 01, 2018 @02:33PM
(#16495357)
Instead of which(1), you could use type, which is aware of builtins and aliases:
[ Parent
| on HN ]
if you use zsh on the other hand..
% which which
which: shell built-in commandcommand is also useful for this sort of thing (with the -v and -V options). It can also be used to ignore shell functions and aliases (without options) so:
$ alias cd=ls
$ cd foo
<lists contents of foo>
$ command cd foo
<changes to directory foo>