Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Exactly what the title says. I'm not having much luck finding the proper documentation to see what -xe does in the following use case:

#!/bin/bash -xe

what do those parameters do and where it is documented?

share|improve this question
    
Are you talking about parameters that are passed to the BASH binary, or are you talking about functions and parameters within the BASH scripting language? –  Richard Keller May 21 '12 at 23:47
    
Referring to the parameters that are passed to the BASH binary, such as: #!/bin/bash -xe –  imaginative May 21 '12 at 23:57

6 Answers 6

up vote 12 down vote accepted

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.

share|improve this answer

From the manpage:

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.

So have a look at the set builtin.

share|improve this answer

Are you thinking of the stuff where you do set -x set -e set -...? running help set gives those.

share|improve this answer
1  
I'm thinking of parameters used such as the following: #!/bin/bash -xe –  imaginative May 21 '12 at 23:58

Type the following on your console to get an explanation of the BASH arguments:

bash -c "help set"

To answer your question:

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

-x Print commands and their arguments as they are executed.

share|improve this answer

Where is the best place to read documentation on what parameters that are passed to bash such as -x and -e are? I tried the man 1 bash, but it doesn't seem to be covered there.

Read the OPTIONS section of the basj manpage.

share|improve this answer

I use excellent Bash Reference Manual as one-stop documentation for Bash language. I found it more useful than man pages. The section relevant for you (description of -e, -x switches can be found here: set builtin

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.