Skip to content

Instantly share code, notes, and snippets.

@endzyme
Created March 21, 2016 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save endzyme/1494ff5bdd85f937a412 to your computer and use it in GitHub Desktop.
Save endzyme/1494ff5bdd85f937a412 to your computer and use it in GitHub Desktop.
#!/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