Quantcast
Channel: What does 'set -e' mean in a Bash script? - Stack Overflow
Browsing all 13 articles
Browse latest View live

Answer by William Pursell for What does 'set -e' mean in a Bash script?

set -e means that the reader of the script cannot know what the script will do when looking at code snippets out of context. (This is a bit tongue-in-cheek, but gets to the heart of the matter.) I have...

View Article


Answer by mxcl for What does 'set -e' mean in a Bash script?

It stops execution of a script if a command fails.A notable exception is an if statement. eg:set -efalseecho never executedset -eif false; then echo never executedfiecho executedfalseecho never executed

View Article

Answer by Rockinroll for What does 'set -e' mean in a Bash script?

set -e The set -e option instructs Bash to immediately exit if any command 1has a non-zero exit status. You wouldn't want to set this for your command-line shell, but in a script it's massively...

View Article

Answer by Miten for What does 'set -e' mean in a Bash script?

cat a.sh#! /bin/bash#going forward report subshell or command exit value if errors#set -e(cat b.txt)echo "hi"./a.sh; echo $?cat: b.txt: No such file or directoryhi0with set -e commented out we see that...

View Article

Answer by Manikandan Raj for What does 'set -e' mean in a Bash script?

Script 1: without setting -e#!/bin/bashdecho "hi"echo "hello"This will throw an error in the line with decho and the program continues to the next line.Script 2: With setting -e#!/bin/bashset -edecho...

View Article


Answer by Kallin Nagelberg for What does 'set -e' mean in a Bash script?

I believe the intention is for the script in question to fail fast.To test this yourself, simply type set -e at a Bash prompt. Now, try running ls. You'll get a directory listing. Now, type lsd. That...

View Article

Answer by tripleee for What does 'set -e' mean in a Bash script?

None of the other answers here discuss the use of set -e aka set -o errexit in Debian package handling scripts. The use of this option is mandatory in these scripts, per Debian policy; the intent is...

View Article

Answer by entpnerd for What does 'set -e' mean in a Bash script?

I found this post while trying to figure out what the exit status was for a script that was aborted due to a set -e. The answer didn't appear obvious to me; hence this answer. Basically, set -e aborts...

View Article


Answer by kenorb for What does 'set -e' mean in a Bash script?

As per bash - The Set Builtin manual, if -e/errexit is set, the shell exits immediately if a pipeline consisting of a single simple command, a list or a compound command returns a non-zero status.By...

View Article


Answer by Gilles Quénot for What does 'set -e' mean in a Bash script?

From help set and Bash Reference Documentation: The Set Builtin: -e Exit immediately if a command exits with a non-zero status.But it's considered bad practice by some (Bash FAQ and IRCFreenode #bash...

View Article

Answer by Robin Green for What does 'set -e' mean in a Bash script?

set -e stops the execution of a script if a command or pipeline has an error - which is the opposite of the default shell behaviour, which is to ignore errors in scripts. Type help set in a terminal to...

View Article

What does 'set -e' mean in a Bash script?

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 script has the following code:#!/bin/bashset -e#...

View Article

Answer by tripleee for What does 'set -e' mean in a Bash script?

I'm belatedly posting a separate answer about the specific code in the question. It has multiple issues.# Automatically added by dh_installinitThis is slightly misleading, in that the author of the...

View Article

Browsing all 13 articles
Browse latest View live