如果您阅读了bash的手册页,您将在OPTIONS部分的顶部找到以下内容:
- All of the single-character shell options documented in the
- description of the set builtin command can be used as options when the
- shell is invoked. In addition,bash interprets the following options
- when it is invoked...
如果您稍后在手册页中阅读了set命令的文档,您会发现:
- -e Exit immediately if a pipeline (which may consist of a
- single simple command),a subshell command enclosed in parentheses,or one of the commands executed as part of a command list enclosed by
- braces (see SHELL GRAMMAR above) exits with a non-zero status.
- -x After expanding each simple command,for command,case
- command,select command,or arithmetic for command,display
- the expanded value of PS4,followed by the command and its
- expanded arguments or associated word list.
换句话说,-e使shell立即退出某些东西会返回一个错误(这通常在shell脚本中用作故障保护机制),-x允许详细执行脚本你可以看到发生了什么.