search

Home  >  Q&A  >  body text

ios - shell脚本中set -e是什么意思

我看了一下某个脚本,最开始的两行是

set -e
set -o pipefail

请问这两句是什么意思呢?

阿神阿神2771 days ago592

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:53:11

    $ set -e

    If any code after this line of code returns a non-zero value, the entire script will exit immediately. The official explanation is to prevent errors from snowballing

    $ set -o pipefail

    The original explanation is as follows:

    If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status,or zero if all commands in the pipeline exit successfully. This option is disabled by default.

    can be understood as:

    Tells bash to return the return value of the first pipe command from right to left that exits with a non-zero status, or 0 if all commands are executed successfully

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:53:11

    Thank you for your answer. My backup script just needs set -e

    reply
    0
  • Cancelreply