!27 grep egrep fgrep 支持关键字高亮显示
From: @licihua Reviewed-by: @overweight Signed-off-by: @overweight
This commit is contained in:
commit
b0266bfe84
11
colorgrep.csh
Executable file
11
colorgrep.csh
Executable 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
7
colorgrep.sh
Executable 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
|
||||
12
grep.spec
12
grep.spec
@ -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
11
grepconf.sh
Executable 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
|
||||
Loading…
x
Reference in New Issue
Block a user