From: Linus Torvalds Date: Wed, 16 Nov 2005 17:38:46 +0000 (-0800) Subject: Disallow empty pattern in "git grep" X-Git-Tag: v0.99.9k~3^2~14 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c0c35d5e419f3bf215103b1e26359aca288c2113;p=git.git Disallow empty pattern in "git grep" For some reason I've done a "git grep" twice with no pattern, which is really irritating, since it just grep everything. If I actually wanted that, I could do "git grep ^" or something. So add a "usage" message if the pattern is empty. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- diff --git a/git-grep.sh b/git-grep.sh index e7a35ebd..44c16130 100755 --- a/git-grep.sh +++ b/git-grep.sh @@ -39,5 +39,9 @@ while : ; do esac shift done +[ "$pattern" ] || { + echo >&2 "usage: 'git grep [pathspec*]'" + exit 1 +} git-ls-files -z "${git_flags[@]}" "$@" | xargs -0 grep "${flags[@]}" -e "$pattern"