bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: doc-strings of the 'command' built-in, as output by help


From: Martin D Kealey
Subject: Re: doc-strings of the 'command' built-in, as output by help
Date: Tue, 26 Nov 2024 12:03:52 +1000

On Tue, 26 Nov 2024 at 05:35, Andrew Davis <addavis@gmail.com> wrote:

> When running 'help command' in the shell, the output contains:
>
> >       -v    print a description of COMMAND similar to the `type' builtin
> >       -V    print a more verbose description of each COMMAND
>
> This seems to be opposite to the actual behaviour of 'command', in which
> '-V' (capital V) produces output similar to 'type'. The text within the
> Bash man-page appears to be correct.
>

The ‘-v’ option does give the minimal output, while ‘-V’ is more verbose;
that much is correct.

What makes it confusing is that the ‘type’ builtin is somewhat verbose by
default.

What constitutes "similar" is in the eye of the reader.

For both ‘command -v’ and ‘command -V’, there are no combinations of
options for ‘type’ that will produce the same output in all cases. In
particular, ‘command -v *NAME*’ where *NAME* is a function just outputs
*NAME* unadorned, but ‘type’ cannot do that.

I suggest:

      -v    if COMMAND is an alias, show the same output as ‘alias -p
COMMAND’;
            if it is an executable, print its path;
            if it is a function, just print its name.
      -V    print a more verbose description of each COMMAND, similar to
‘type -a’

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.

Is there a reason why they differ only in that case?
Would anyone object to adjusting the output of ‘command -V’ to be identical
to ‘type -a’?

-Martin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]