What does set -e mean in a bash script?

后端 未结 8 961
醉酒成梦
醉酒成梦 2020-11-22 15:46

I\'m studying the content of this preinst file that the script executes before that package is unpacked from its Debian archive (.deb) file.

The scr

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 16:10

    From help set :

      -e  Exit immediately if a command exits with a non-zero status.
    

    But it's considered bad practice by some (bash FAQ and irc freenode #bash FAQ authors). It's recommended to use:

    trap 'do_something' ERR
    

    to run do_something function when errors occur.

    See http://mywiki.wooledge.org/BashFAQ/105

提交回复
热议问题