What does passing the -xe parameters to /bin/bash do

If you read the man page for bash you’ll find the following at the top of the OPTIONS section:

 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...

And if you read the documentation for the set command later on in the man page, you’ll find:

 -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.

In other words, -e makes the shell exit immediately whenever
something returns an error (this is often used in shell scripts as a
failsafe mechanism), and -x enables verbose execution of scripts so
that you can see what’s happening.

Leave a Comment