!27 grep egrep fgrep 支持关键字高亮显示

From: @licihua 
Reviewed-by: @overweight 
Signed-off-by: @overweight
This commit is contained in:
openeuler-ci-bot 2022-05-19 14:06:58 +00:00 committed by Gitee
commit b0266bfe84
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 40 additions and 1 deletions

11
colorgrep.csh Executable file
View File

@ -0,0 +1,11 @@
# color-grep initialization
/usr/libexec/grepconf.sh -c
if ( $status == 1 ) then
exit
endif
alias grep 'grep --color=auto'
alias egrep 'egrep --color=auto'
alias fgrep 'fgrep --color=auto'

7
colorgrep.sh Executable file
View File

@ -0,0 +1,7 @@
# color-grep initialization
/usr/libexec/grepconf.sh -c || return
alias grep='grep --color=auto' 2>/dev/null
alias egrep='egrep --color=auto' 2>/dev/null
alias fgrep='fgrep --color=auto' 2>/dev/null

View File

@ -1,10 +1,13 @@
Name: grep
Version: 3.7
Release: 3
Release: 4
Summary: A string search utility
License: GPLv3+
URL: http://www.gnu.org/software/grep/
Source0: https://ftp.gnu.org/gnu/grep/grep-%{version}.tar.xz
Source1: colorgrep.sh
Source2: colorgrep.csh
Source3: grepconf.sh
Patch1: backport-grep-avoid-sticky-problem-with-f-f.patch
Patch2: backport-grep-s-does-not-suppress-binary-file-matches.patch
@ -28,6 +31,9 @@ CPPFLAGS="-I%{_includedir}/pcre" CFLAGS="$RPM_OPT_FLAGS -fsigned-char"
%make_install
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 -Dpm 755 %{SOURCE3} $RPM_BUILD_ROOT%{_libexecdir}/grepconf.sh
%pre
%preun
@ -39,14 +45,18 @@ make check
%files
%{_datadir}/locale/*
%config(noreplace) %{_sysconfdir}/profile.d/colorgrep.*sh
%doc NEWS README THANKS TODO
%license COPYING AUTHORS
%{_bindir}/*grep
%{_libexecdir}/grepconf.sh
%{_infodir}/grep.info.gz
%{_mandir}/man1/*grep.1.gz
%changelog
* Thu May 19 2022 licihua <licihua@huawei.com> -3.7-4
- Added coloring aliases to fgrep egrep and grep
* Fri Mar 18 2022 yangzhuangzhuang <yangzhuangzhuang1@h-partners.com> - 3.7-3
- The -s option no longer suppresses "binary file matches" messages

11
grepconf.sh Executable file
View File

@ -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