Last active
January 16, 2016 02:12
-
-
Save nhoag/e97200b008761cdab183 to your computer and use it in GitHub Desktop.
Bash Script Boilerplate
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 | |
set -a ; set -o errexit ; set -o nounset | |
function usage() { | |
cat <<EOF | |
Usage: ${0} ARG | |
OPTIONS: | |
-h Show usage | |
EOF | |
exit | |
} | |
while getopts ":h" OPTION; do | |
case $OPTION in | |
h) usage ;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
if [ $# -eq 0 ]; then | |
usage | |
fi | |
if [[ ! -f $HOME/.example ]]; then | |
printf 'Enter username for Example: ' | |
read -r EXAMPLE_USER | |
printf 'Enter password for Example: ' | |
read -rs EXAMPLE_PASS | |
echo | |
echo "${EXAMPLE_USER}:${EXAMPLE_PASS}" \ | |
> "$HOME/.example" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment