1

I learned that from an instruction:

Co-processing does two things at the same time. It spawns a subshell in background mode and executes a command within that subshell.

[root@iz2ze9wve43n2nyuvmsfx5z ~]# coproc ( sleep 10; sleep 2 )
[1] 32508
[root@iz2ze9wve43n2nyuvmsfx5z ~]# jobs
[1]+  Running                 coproc COPROC ( sleep 10; sleep 2 ) &

When I refer to its manual, get an error as feedback

root@iz2ze9wve43n2nyuvmsfx5z ~]# man coproc
No manual entry for coproc
[root@iz2ze9wve43n2nyuvmsfx5z ~]# coproc --info
[1] 32579
[root@iz2ze9wve43n2nyuvmsfx5z ~]# bash: line 25: --info: command not found

[1]+  Exit 127                coproc COPROC --info

help works

[root@iz2ze9wve43n2nyuvmsfx5z ~]# help coproc
coproc: coproc [NAME] command [redirections]
    Create a coprocess named NAME.

    Execute COMMAND asynchronously, with the standard output and standard
    input of the command connected via a pipe to file descriptors assigned
    to indices 0 and 1 of an array variable NAME in the executing shell.
    The default NAME is "COPROC".

    Exit Status:
    Returns the exit status of COMMAND.

This's very confusing,
How could I have a big picture of the commands on which manuals I can reach to? How to distinguish them?

Kusalananda
  • 333,661
Wizard
  • 2,503

1 Answers1

2

coproc is a shell keyword in the bash shell. Keywords don't usually have their own man manuals but are documented in the shell's manual (in this case in the manual of bash, man bash). The bash shell also provides a help command (in itself, help is a built in command) that provides a sort of manual for built in commands and special keywords like coproc.

There's another built in command in bash, type, that will help you distinguish whether a command is external or built in:

$ type coproc
coproc is a shell keyword
$ type help
help is a shell builtin
$ type type
type is a shell builtin
$ type ls
ls is /bin/ls

For things that are not external commands in bash (only ls is external in the above example), use help or read the bash manual (which is usually more detailed than what help will show you). For anything else, use man.

Note that the shell may also provide several commands as builtins even though they are also available as external commands. Common examples of these are echo, printf, test and [ etc., but a shell may in fact provide internal versions of any command. This is usually done for performance reasons or to provide an enhanced version of a command.

Commands that are both internal and external will be documented in both the shell's manual and in an external manual, and they may well work differently. The type command in bash will tell you which one will be used and you can force the use of a built in command using the builtin command, or an external command by using it with its full path (e.g. /bin/echo).

Some commands, like set, read and cd are usually only provided as built in commands as they modify the environment of the current shell. These will be documented by help in bash and in more detail in the shell's manual.

Kusalananda
  • 333,661
  • 1
    For a manual the size of bash's, info is more appropriate. info bash coproc (and press , for the next index entry or follow the link to Coprocesses from the entry for the COPROC array variable) – Stéphane Chazelas Oct 25 '18 at 07:17