将-xe参数传递给/ bin / bash的做法是什么

前端之家收集整理的这篇文章主要介绍了将-xe参数传递给/ bin / bash的做法是什么前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
正是标题所说的.我没有太多运气找到正确的文档来查看-xe在以下用例中的作用:

#!/ bin / bash -xe

这些参数做了什么以及记录在哪里?

如果您阅读了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允许详细执行脚本你可以看到发生了什么.

猜你在找的Bash相关文章