Created
April 16, 2012 09:59
-
-
Save dekokun/2397408 to your computer and use it in GitHub Desktop.
シェルスクリプトで、引数が0以上の整数であることをチェック
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
usage() | |
{ | |
echo $0 hoge | |
} | |
if [ -z $1 ]; then | |
usage | |
exit | |
else | |
expr $1 + 1 >/dev/null 2>&1 | |
fi | |
if [ $? -ne 1 -a $? -ne 0 ]; then | |
echo "must be numeric" | |
exit | |
elif [ $1 -lt 0 ]; then | |
echo "must be more than 0" | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment