Created
September 5, 2017 14:11
-
-
Save Buravo46/1fd0300e067e7959a88b45716c27f335 to your computer and use it in GitHub Desktop.
【Bash】コマンド作成用のテンプレート
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 | |
# Command | |
COMMAND=$(basename ${0}) | |
shift | |
# Default | |
OPTION="DEFAULT" | |
function usage { | |
cat <<EOF | |
Usage: | |
${COMMAND} [<options>] | |
Options: | |
--option -o option | |
--help -h help | |
EOF | |
} | |
function command { | |
echo "command "${OPTION} | |
} | |
# OPTION | |
while [ $# -gt 0 ]; | |
do | |
case ${1} in | |
--option|-o) | |
OPTION=${2} | |
shift | |
;; | |
--help|-h) | |
usage | |
shift | |
exit 0 | |
;; | |
*) | |
echo "[ERROR] ${COMMAND} ${1}" | |
usage | |
exit 1 | |
;; | |
esac | |
shift | |
done | |
command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment