[PATCH 10/25] git-grep: Print usage message on '-h' and '--help'.
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
---
git-grep.sh | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
b375c3ad7c6ce4d6cda208c61828f8ff72cb7d53
diff --git a/git-grep.sh b/git-grep.sh
index 44c1613..e6acc41 100755
--- a/git-grep.sh
+++ b/git-grep.sh
@@ -3,6 +3,11 @@
# Copyright (c) Linus Torvalds, 2005
#
+usage () {
+ echo >&2 "usage: $0 <option>... <pattern> [pathspec*]"
+ exit 1
+}
+
pattern=
flags=()
git_flags=()
@@ -26,6 +31,9 @@ while : ; do
shift
break
;;
+ -h|--h|--he|--hel|--help)
+ usage
+ ;;
-*)
flags=("${flags[@]}" "$1")
;;
@@ -40,8 +48,7 @@ while : ; do
shift
done
[ "$pattern" ] || {
- echo >&2 "usage: 'git grep <pattern> [pathspec*]'"
- exit 1
+ usage
}
git-ls-files -z "${git_flags[@]}" "$@" |
xargs -0 grep "${flags[@]}" -e "$pattern"
--
0.99.9.GIT