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

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

$
0
0

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 command is not recognized and will return an error code, and so your Bash prompt will close (due to set -e).

Now, to understand this in the context of a 'script', use this simple script:

#!/bin/bash# set -elsdls

If you run it as is, you'll get the directory listing from the ls on the last line. If you uncomment the set -e and run again, you won't see the directory listing as bash stops processing once it encounters the error from lsd.


Viewing all articles
Browse latest Browse all 13

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>