Refactor common code into a function
This commit is contained in:
parent
a0a9e7dc03
commit
f3eab6afca
1 changed files with 11 additions and 9 deletions
|
@ -174,6 +174,14 @@ exit_if_extra_operand()
|
|||
}
|
||||
|
||||
|
||||
exit_if_unrecognized_option()
|
||||
{
|
||||
echo "$0: unrecognized option '$1'"
|
||||
echo "Try '$0 --help' for more information."
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Usage: $0 [-v | --verbose] create [--candidate-registry]"
|
||||
|
@ -197,9 +205,7 @@ while [[ "$1" == -* ]]; do
|
|||
exec 42>&2
|
||||
;;
|
||||
* )
|
||||
echo "$0: unrecognized option '$1'"
|
||||
echo "Try '$0 --help' for more information."
|
||||
exit 1
|
||||
exit_if_unrecognized_option $1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -221,9 +227,7 @@ case $op in
|
|||
registry=$registry_candidate
|
||||
;;
|
||||
* )
|
||||
echo "$0: unrecognized option '$1'"
|
||||
echo "Try '$0 --help' for more information."
|
||||
exit 1
|
||||
exit_if_unrecognized_option $1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -235,9 +239,7 @@ case $op in
|
|||
while [[ "$1" == -* ]]; do
|
||||
case $1 in
|
||||
* )
|
||||
echo "$0: unrecognized option '$1'"
|
||||
echo "Try '$0 --help' for more information."
|
||||
exit 1
|
||||
exit_if_unrecognized_option $1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue