Created
January 30, 2012 04:46
-
-
Save BenGardiner/1702594 to your computer and use it in GitHub Desktop.
An example of how to do 'verbose' mode and a dry-run mode together
This file contains 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 | |
function echo_and_exec() | |
{ | |
echo "Executing $@" ; "$@" | |
} | |
function set_exec() | |
{ | |
if [ -z "${DRYRUN}" ]; then | |
DRYRUN="false" | |
fi | |
if [ -z "${VERBOSE}" ]; then | |
VERBOSE="false" | |
fi | |
if ${DRYRUN}; then | |
EXEC="echo Not Executing " | |
elif ${VERBOSE}; then | |
EXEC="echo_and_exec" | |
else | |
EXEC="" | |
fi | |
} | |
VERBOSE=true set_exec | |
${EXEC} ls | |
DRYRUN=true set_exec | |
${EXEC} ls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment