Fix unrecognized flag handling

If the values in a=b format matches -(.*), unrecognized
flag error is triggeed, using ^pattern to handle this.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2017-03-28 21:59:53 -07:00
parent f865312fb5
commit aca0536725
No known key found for this signature in database
GPG Key ID: 5C02521D7B216AD6

View File

@ -134,7 +134,7 @@ main() {
swap_context
elif [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
usage
elif [[ "${1}" =~ -(.*) ]]; then
elif [[ "${1}" =~ ^-(.*) ]]; then
echo "error: unrecognized flag" >&2; usage
elif [[ "${1}" =~ (.+)=(.+) ]]; then
alias_context "${BASH_REMATCH[2]}" "${BASH_REMATCH[1]}"