mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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>
This commit is contained in:
@@ -41,7 +41,7 @@ resolve_full_httpd () {
|
||||
case "$httpd" in
|
||||
*apache2*|*lighttpd*)
|
||||
# ensure that the apache2/lighttpd command ends with "-f"
|
||||
if ! echo "$httpd" | grep -- '-f *$' >/dev/null 2>&1
|
||||
if ! echo "$httpd" | sane_grep -- '-f *$' >/dev/null 2>&1
|
||||
then
|
||||
httpd="$httpd -f"
|
||||
fi
|
||||
@@ -297,8 +297,8 @@ EOF
|
||||
|
||||
# check to see if Dennis Stosberg's mod_perl compatibility patch
|
||||
# (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
|
||||
if test -f "$module_path/mod_perl.so" && grep 'MOD_PERL' \
|
||||
"$GIT_DIR/gitweb/gitweb.cgi" >/dev/null
|
||||
if test -f "$module_path/mod_perl.so" &&
|
||||
sane_grep 'MOD_PERL' "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null
|
||||
then
|
||||
# favor mod_perl if available
|
||||
cat >> "$conf" <<EOF
|
||||
@@ -316,7 +316,7 @@ EOF
|
||||
# plain-old CGI
|
||||
resolve_full_httpd
|
||||
list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
|
||||
$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
|
||||
$list_mods | sane_grep 'mod_cgi\.c' >/dev/null 2>&1 || \
|
||||
echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
|
||||
cat >> "$conf" <<EOF
|
||||
AddHandler cgi-script .cgi
|
||||
|
||||
Reference in New Issue
Block a user