gpt4 book ai didi

manpage - set -e 和 set -a 在 bash 中做什么。我可以使用 set 命令的其他选项是什么

转载 作者:行者123 更新时间:2023-12-04 05:16:58 28 4
gpt4 key购买 nike

关闭。这个问题不符合 Stack Overflow guidelines 。它目前不接受答案。












想改善这个问题吗?更新问题,以便堆栈溢出为 on-topic

4年前关闭。



Improve this question




我想知道以下命令在 bash 中的作用。

  • 设置-e
  • 设置-a

  • 我可以与 set 一起使用的其他选项是什么,它们是什么意思。

    最佳答案

    man page :

    -a Mark variables and function which are modified or created for export to the environment of subsequent commands

    -e Exit immediately if a pipeline (see Pipelines), which may consist of a single simple command (see Simple Commands), a list (see Lists), or a compound command (see Compound Commands) returns a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command’s return status is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit. A trap on ERR, if set, is executed before the shell exits.

    This option applies to the shell environment and each subshell environment separately (see Command Execution Environment), and may cause subshells to exit before executing all the commands in the subshell.

    If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body will be affected by the -e setting, even if -e is set and a command returns a failure status. If a compound command or shell function sets -e while executing in a context where -e is ignored, that setting will not have any effect until the compound command or the command containing the function call completes.

    关于manpage - set -e 和 set -a 在 bash 中做什么。我可以使用 set 命令的其他选项是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39162846/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com