Last active
August 29, 2015 14:24
-
-
Save remijouannet/fa4d661b730f5bdbc6fe to your computer and use it in GitHub Desktop.
bash_getops
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
function args { | |
d=false; | |
while getopts ":h:g:d" opt "$@"; do | |
case $opt in | |
h) | |
h=$OPTARG; | |
;; | |
g) | |
g=$OPTARG; | |
;; | |
d) | |
d=true; | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2; | |
exit 1; | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." >&2; | |
exit 1; | |
;; | |
esac | |
done | |
if [ -z $h ];then echo "please specify a remote server with -h parameter.";exit 1;fi | |
if [ -z $g ];then echo "please specify a group to mirror with -g parameter.";exit 1;fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment