diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-11-23 15:56:32 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-11-23 16:31:07 -0800 |
commit | e1622bfcbad680225ad5c337e4778df88389227e (patch) | |
tree | 9a652f7a3e3a2999dd8469ddd6bbedda05cb3d36 /git-am.sh | |
parent | 7b1042292d5dc18508213c3be888b740d02f02e3 (diff) | |
download | git-e1622bfcbad680225ad5c337e4778df88389227e.tar.gz |
Protect scripted Porcelains from GREP_OPTIONS insanity
If the user has exported the GREP_OPTIONS environment variable, the output
from "grep" and "egrep" in scripted Porcelains may be different from what
they expect. For example, we may want to count number of matching lines,
by "grep" piped to "wc -l", and GREP_OPTIONS=-C3 will break such use.
The approach taken by this change to address this issue is to protect only
our own use of grep/egrep. Because we do not unset it at the beginning of
our scripts, hook scripts run from the scripted Porcelains are exposed to
the same insanity this environment variable causes when grep/egrep is used
to implement logic (e.g. "grep | wc -l"), and it is entirely up to the
hook scripts to protect themselves.
On the other hand, applypatch-msg hook may want to show offending words in
the proposed commit log message using grep to the end user, and the user
might want to set GREP_OPTIONS=--color to paint the match more visibly.
The approach to protect only our own use without unsetting the environment
variable globally will allow this use case.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-am.sh')
-rwxr-xr-x | git-am.sh | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -205,7 +205,7 @@ check_patch_format () { # and see if it looks like that they all begin with the # header field names... sed -n -e '/^$/q' -e '/^[ ]/d' -e p "$1" | - LC_ALL=C egrep -v '^[!-9;-~]+:' >/dev/null || + sane_egrep -v '^[!-9;-~]+:' >/dev/null || patch_format=mbox fi } < "$1" || clean_abort @@ -554,7 +554,7 @@ do stop_here $this # skip pine's internal folder data - grep '^Author: Mail System Internal Data$' \ + sane_grep '^Author: Mail System Internal Data$' \ <"$dotest"/info >/dev/null && go_next && continue |