Skip to content

Instantly share code, notes, and snippets.

@Buravo46
Created September 5, 2017 14:11
Show Gist options
  • Save Buravo46/1fd0300e067e7959a88b45716c27f335 to your computer and use it in GitHub Desktop.
Save Buravo46/1fd0300e067e7959a88b45716c27f335 to your computer and use it in GitHub Desktop.
【Bash】コマンド作成用のテンプレート
#! /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