On Tue, 26 Nov 2024 at 12:43, Lawrence Velázquez <v...@larryv.me> wrote:

> On Mon, Nov 25, 2024, at 9:03 PM, Martin D Kealey wrote:
> > I keep "similar" there because ‘type -a COMMAND’ shows all possible
> matches
> > for COMMAND, whereas ‘command -V’ only does that when COMMAND is NOT an
> > alias.
>
> I'm not seeing that "command -V" behavior.
>
>         $ type -a bash
>         bash is /opt/local/bin/bash
>         bash is /bin/bash
>         $ command -V bash
>         bash is /opt/local/bin/bash
>

You're quite correct, I had only done a cursory check to see that it didn't
print a function or path when given an alias. I didn't check other
combinations, or multiple paths.

Point is, there's no way to get the same output from both ‘command’ and
‘type’. In some sense, that's the point, but then we probably shouldn't
describe one in terms of the other.

I'm not convinced that ‘command’ should mention aliases at all, since
‘command -v "$var"’ should tell you what ‘"$var"’ will do. What it *won't*
do is be expanded as an alias. Fortunately scripts don't generally define
or use aliases, so it's unlikely to be a problem in practice, but just in
case perhaps could we have something like ‘command -Av’ to skip alias
lookup?

-Martin

Reply via email to