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

2024-11-25 Thread Andrew Davis
When running 'help command' in the shell, the output contains:

>   -vprint a description of COMMAND similar to the `type' builtin
>   -Vprint 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.

Other info:

- version number and release status of Bash: 5.2.32(1)-release
(x86_64-pc-linux-gnu)
- The machine and OS that it is running on: Debian trixie (testing)
container running under LXD on ChromeOS

Best,
Andrew

--
Andrew D. Davis, PhD
PGP Key : 0xC1665F6A


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

2024-11-26 Thread Andrew Davis
On Mon, Nov 25, 2024 at 9:04 PM Martin D Kealey 
wrote:

>
> For both ‘command -v’ and ‘command -V’, there are no combinations of
> options for ‘type’ that will produce the same output in all cases.
>

For executables, aliases, functions, built-ins, and keywords, the output of
`command -V` (capital V) is identical to the output of `type` (with no
flags). To wit:

foo() { echo hi; }

alias bar=foo

for c in foo bar bash echo for
do

a=$( command -V "$c" )
b=$( type "$c" )
[[ $a == $b ]] && echo same || echo nope

done

#same

#same
#same
#same
#same


To be clear, I have no problem with the behaviour of 'command' itself. My
report was only meant to file a bug against the doc-strings output by 'help
command'.  Maybe I could suggest a starting point for a fix, using the
language from the standard linked earlier, and the output of 'help type':

> -vFor each COMMAND, print a string to indicate how it would be
interpreted by the shell.  The command word is printed for shell functions,
built-ins, and keywords, while a pathname is printed for executables found
in PATH. Aliases are printed with their definition.
>
> -VFor each COMMAND, print a more verbose description of how it would
be interpreted if used as a command name, similar to the 'type' built-in.

- Andrew