Skip to content

Instantly share code, notes, and snippets.

@jiro4989
Created December 10, 2017 05:56
Show Gist options
  • Save jiro4989/64523cdadd10e09e35c89ba31504dcac to your computer and use it in GitHub Desktop.
Save jiro4989/64523cdadd10e09e35c89ba31504dcac to your computer and use it in GitHub Desktop.
シェルでオプション引数などの設定をする時のコード
# 1. caseの末尾には;;が必須
# 2. s:cの:はその後に文字列が必要
# 3. case内の$OPTARGで文字列を取得
srcfile=?
compileflag=false
while getopts s:c opts; do
case $opts in
s) srcfile=$OPTARG;;
c) compileflag=true;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment