[Logwatch-Devel] remove unnecessary bashery

Georgi Georgiev chutz at gg3.net
Fri Sep 9 19:57:39 MST 2005


Hi, list,

the current implementation of "script/shared/onlycontains" and
"script/shared/remove" is far from optimal. Has anyone considered the
following trivial patch to handle this internally in perl:

Index: scripts/shared/onlycontains
===================================================================
RCS file: /var/cvs/logwatch/scripts/shared/onlycontains,v
retrieving revision 1.12
diff -u -r1.12 onlycontains
--- scripts/shared/onlycontains	25 May 2005 22:33:15 -0000	1.12
+++ scripts/shared/onlycontains	10 Sep 2005 02:53:22 -0000
@@ -12,6 +12,10 @@
 
 # Just does a case-insensitive egrep ;)
 
-system("egrep -i \"@ARGV\"");
+#system("egrep -i \"@ARGV\"");
+my $re = "@ARGV";
+while (<STDIN>) {
+   m/$re/i and print;
+}
 
 # vi: shiftwidth=3 syntax=perl tabstop=3 et
Index: scripts/shared/remove
===================================================================
RCS file: /var/cvs/logwatch/scripts/shared/remove,v
retrieving revision 1.12
diff -u -r1.12 remove
--- scripts/shared/remove	25 May 2005 22:33:15 -0000	1.12
+++ scripts/shared/remove	10 Sep 2005 02:53:22 -0000
@@ -15,5 +15,9 @@
 
 #/bin/egrep -vi "$@"
 system("egrep -vi \"@ARGV\"");
+my $re = "@ARGV";
+while (<STDIN>) {
+   m/$re/i or print;
+}
 
 # vi: shiftwidth=3 syntax=perl tabstop=3 et

-- 
 >   Georgi Georgiev    > Coming together is a beginning; keeping       >
<     chutz at gg3.net    <  together is progress; working together is    <
 >  +81(90)2877-8845    > success.                                      >


More information about the Logwatch-Devel mailing list