Create a gist now

Instantly share code, notes, and snippets.

anonymous /example-with-set-e.sh
Created Jun 20, 2017

What would you like to do?
Demonstrating What does set -e mean? Simple: Run each file with your internet connection turned on/off and spot the difference.
#!/bin/bash
set -e
wget -O /tmp/example.html example.com; cat /tmp/example.html | wc > /tmp/wordcount.txt
echo "Hello! If we got this far, eveything was a sucess hooraryy!"
#!/bin/bash
# If wget fails in this script, the pipe to wc will continue regardless
# This might be bad and not what we want.
wget -O /tmp/example.html example.com; cat /tmp/example.html | wc > /tmp/wordcount.txt
echo "Hello! If we got this far, eveything was a sucess hooraryy!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment