Bash has the built-in command "type", which indicates how each argument would be interpreted if used as a command name, for instance:
$ type myfunction
myfunction is a function
myfunction ()
{
echo hello
}
$ type myfunctionalias
myfunctionalias is aliased to `myfunction'
$ type python
python is /usr/bin/python
In the last case, /usr/bin/python is a link, and its target is again a link:
$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 7 Feb 5 09:05 /usr/bin/python -> python3
$ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 7 Feb 5 09:05 /usr/bin/python -> python3.13
$ ls -l /usr/bin/python3.13
-rwxr-xr-x 1 root root 14352 Feb 5 09:05 /usr/bin/python3.13
It is possible to resolve a link with "readlink -f", however it is tedious to do it manually, since i requires up to three steps: type to resolve the alias source, type to resolve the alias target, and readlink to resolve any link.
In practice, I am more often interested in what will actually be executed, rather than the single resolution steps. So I need a "type"-like tool that resolves the aliases and the links, ideally:
$ clevertype python
/usr/bin/python3.13
$ clevertype --verbose python
python is /usr/bin/python
/usr/bin/python links to /usr/bin/python3
/usr/bin/python3 links to /usr/bin/python3.13
Result: python resolves to /usr/bin/python3.13
And:
$ clevertype pythonalias
pythonalias resolves to /usr/bin/python3.13
$ clevertype --verbose pythonalias
pythonalias is aliased to `/usr/bin/python'
/usr/bin/python links to /usr/bin/python3
/usr/bin/python3 links to /usr/bin/python3.13
Result: pythonalias resolves to /usr/bin/python3.13
Does such a tool exist?
type-like tool that resolves the aliases and the links" => I don't think you can "resolve" an "alias" recursively as it can contain shell code.