Created
March 21, 2016 20:39
-
-
Save endzyme/1494ff5bdd85f937a412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Quick Dry Run Example Bash | |
dry=$1 | |
function run () { | |
if [ ! -z "$dry" ]; then | |
echo "WOULD HAVE $@" | |
else | |
$@ | |
fi | |
} | |
run echo hello there | |
run curl -I google.com | |
this=$(run curl -I yahoo.com) | |
run echo $this | |
run echo $that | |
# Notes you'll want to avoid trying to set variables with run() as it | |
# doesn't eval and will error out saying "this=that" Command not found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment