mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 09:40:21 +00:00
Check for options mixed with positional arguments and throw error.
This commit is contained in:
parent
764d0581c4
commit
aff51a1cc8
1 changed files with 16 additions and 2 deletions
|
@ -63,17 +63,29 @@ do
|
|||
v|version ) echo "$0 -- Version $ScriptVersion"; exit 0 ;;
|
||||
c|config-dir ) TEMP_CONFIG_DIR="$OPTARG" ;;
|
||||
|
||||
\? ) echo "\n Option does not exist : $OPTARG\n"
|
||||
usage; exit 1 ;;
|
||||
\? ) echo "\n Option does not exist : $OPTARG\n"
|
||||
usage; exit 1 ;;
|
||||
|
||||
esac # --- end of case ---
|
||||
done
|
||||
shift $(($OPTIND-1))
|
||||
|
||||
__check_unparsed_options() {
|
||||
shellopts="$1"
|
||||
unparsed_options=$( echo "$shellopts" | grep -e '[\-|\-\-][a-z]' )
|
||||
if [ "x$unparsed_options" != "x" ]; then
|
||||
usage
|
||||
echo
|
||||
echo " * ERROR: options come before install arguments"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Define installation type
|
||||
if [ "$#" -eq 0 ];then
|
||||
ITYPE="stable"
|
||||
else
|
||||
__check_unparsed_options "$*"
|
||||
ITYPE=$1
|
||||
shift
|
||||
fi
|
||||
|
@ -87,12 +99,14 @@ if [ $ITYPE = "git" ]; then
|
|||
if [ "$#" -eq 0 ];then
|
||||
GIT_REV="master"
|
||||
else
|
||||
__check_unparsed_options "$*"
|
||||
GIT_REV="$1"
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
__check_unparsed_options "$*"
|
||||
usage
|
||||
echo
|
||||
echo " * ERROR: Too many arguments."
|
||||
|
|
Loading…
Add table
Reference in a new issue