Skip to content

Instantly share code, notes, and snippets.

@takakabe
Created May 24, 2020 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takakabe/3fe31ae6612954b51da5e5643dcc6cdf to your computer and use it in GitHub Desktop.
Save takakabe/3fe31ae6612954b51da5e5643dcc6cdf to your computer and use it in GitHub Desktop.
#!/bin/bash
# ↓ここを編集
while getopts w-:h-: opt; do
optarg="${OPTARG}"
if [[ "${opt}" = - ]]; then
opt="-${OPTARG%%=*}"
optarg="${OPTARG/${OPTARG%%=*}/}"
optarg="${optarg#=}"
set +u
if [[ -z "${optarg}" ]] && [[ ! "${!OPTIND}" = "-*" ]]; then
optarg="${!OPTIND}"
shift
fi
fi
# ↓ここも編集
case "-${opt}" in
-w|--wawawa)
echo 'wawawa'
;;
-h|--help)
echo 'usage'
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment