if --help 在终端中不起作用

if --help 在终端中不起作用
if --help

在终端中不起作用,为什么?

Linux Mint 19.3 肉桂 64 位

外壳: 巴什

答案1

请参阅:help --helphelp

Display information about builtin commands.

help if

if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
    Execute commands based on conditional.

    The `if COMMANDS' list is executed.  If its exit status is zero, then the
    `then COMMANDS' list is executed.  Otherwise, each `elif COMMANDS' list is
    executed in turn, and if its exit status is zero, the corresponding
    `then COMMANDS' list is executed and the if command completes.  Otherwise,
    the `else COMMANDS' list is executed, if present.  The exit status of the
    entire construct is the exit status of the last command executed, or zero
    if no condition tested true.

    Exit Status:
    Returns the status of the last command executed.

答案2

我不确定您可能在哪里看到过这项工作,但if它是 shell 的一个关键字,用于测试构造;它不是命令,因此不能使用通常的--help选项来调用。相反,它将阻塞并等待进一步的输入(即测试语句),直到您按下Ctrl-C强制退出已启动的命令。

如果您需要有关如何if在 shell 脚本中使用关键字的帮助,Bash 参考手册或 Lhunath & GreyCat's重击指南可能是一个很好的起点。

相关内容