Created
May 12, 2014 14:15
-
-
Save im6e/b592030c29f100b564f5 to your computer and use it in GitHub Desktop.
dry-run function
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 | |
while getopts d OPT | |
do | |
case $OPT in | |
"d" ) DRY="y"; echo "[DRY RUN MODE]" ;; | |
esac | |
done | |
function execute() { | |
echo "COMMAND: ${@}" | |
if [[ $DRY == "y" ]]; then | |
return 0 | |
fi | |
eval "$@" | |
} | |
execute "ls -la" | |
execute "pwd" | |
execute "echo \'Hello, world.\'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment