mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
abort git-alias when too many arguments given.
Avoid incorrect usage probably because of the missing quotes, like "git alias cm checkout master"
This commit is contained in:
parent
2113e8c1d7
commit
98a1820d39
|
|
@ -1,7 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
usage() {
|
||||
cat <<HERE
|
||||
usage: git alias # list all aliases
|
||||
or: git alias <search-pattern> # show aliases matching pattern
|
||||
or: git alias <alias-name> <command> # alias a command
|
||||
HERE
|
||||
}
|
||||
|
||||
case $# in
|
||||
0) git config --get-regexp 'alias.*' | sed 's/^alias\.//' | sed 's/[ ]/ = /' | sort ;;
|
||||
1) git alias | grep -e "$1" ;;
|
||||
*) git config --global alias."$1" "$2" ;;
|
||||
2) git config --global alias."$1" "$2" ;;
|
||||
*) >&2 echo "error: too many arguments." && usage && exit 1 ;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Reference in a new issue