Skip to content

Instantly share code, notes, and snippets.

@remijouannet
Last active August 29, 2015 14:24
Show Gist options
  • Save remijouannet/fa4d661b730f5bdbc6fe to your computer and use it in GitHub Desktop.
Save remijouannet/fa4d661b730f5bdbc6fe to your computer and use it in GitHub Desktop.
bash_getops
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