diff --git a/colorgrep.csh b/colorgrep.csh index 0b76c97..b3152a6 100644 --- a/colorgrep.csh +++ b/colorgrep.csh @@ -1,13 +1,9 @@ # color-grep initialization -if ( -r /etc/GREP_COLORS ) then - set color_none=`sed -n '/^COLOR.*none/Ip' < /etc/GREP_COLORS` - if ( "$color_none" != '' ) then - unset color_none - exit - endif - unset color_none +/usr/libexec/grepconf.sh -c +if ( $status == 1 ) then + exit endif alias grep 'grep --color=auto' diff --git a/colorgrep.sh b/colorgrep.sh index 57f7aba..cd0539c 100644 --- a/colorgrep.sh +++ b/colorgrep.sh @@ -1,8 +1,6 @@ # color-grep initialization -if [ -r /etc/GREP_COLORS ]; then - grep -qi "^COLOR.*none" /etc/GREP_COLORS >/dev/null 2>/dev/null && return -fi +/usr/libexec/grepconf.sh -c || return alias grep='grep --color=auto' 2>/dev/null alias egrep='egrep --color=auto' 2>/dev/null diff --git a/grep.spec b/grep.spec index a4798b0..7458394 100644 --- a/grep.spec +++ b/grep.spec @@ -3,13 +3,14 @@ Summary: Pattern matching utilities Name: grep Version: 2.20 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv3+ Group: Applications/Text Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.xz Source1: colorgrep.sh Source2: colorgrep.csh Source3: GREP_COLORS +Source4: grepconf.sh # upstream ticket 39444 Patch0: grep-2.20-man-fix-gs.patch # upstream ticket 39445 @@ -57,6 +58,7 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d install -pm 644 %{SOURCE1} %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d install -pm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir} +install -Dpm 755 %{SOURCE4} $RPM_BUILD_ROOT%{_libexecdir}/grepconf.sh %find_lang %name @@ -85,8 +87,13 @@ fi %config(noreplace) %{_sysconfdir}/GREP_COLORS %{_infodir}/*.info*.gz %{_mandir}/*/* +%{_libexecdir}/grepconf.sh %changelog +* Wed Aug 20 2014 Jaroslav Škarvada - 2.20-5 +- Added script to check whether grep is coloured + Resolves: rhbz#1034631 + * Sat Aug 16 2014 Fedora Release Engineering - 2.20-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild diff --git a/grepconf.sh b/grepconf.sh new file mode 100644 index 0000000..418af0b --- /dev/null +++ b/grepconf.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +case "$1" in + -c | --interactive-color) + ! grep -qsi "^COLOR.*none" /etc/GREP_COLORS + ;; + *) + echo >&2 "Invalid / no option passed, so far only -c | --interactive-color is supported." + exit 1 + ;; +esac