Subject: [alpine-aports] [PATCH] main/sysklogd: remove GNUism and use POSIX Extended Regular Expressions (EREs)

From: Nathan Angelacos <[email-masked]>
Date: Wed, 11 Mar 2015 21:28:25 +0000

---
 main/sysklogd/sysklogd.daily | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/main/sysklogd/sysklogd.daily b/main/sysklogd/sysklogd.daily
index 723413d..3d98e8e 100755
--- a/main/sysklogd/sysklogd.daily
+++ b/main/sysklogd/sysklogd.daily
@@ -1,7 +1,7 @@
 #!/bin/sh
 # This is a shell script replacement for the sysklogd's logrotate cron script
 # and syslogd-listfiles perl script. 
-# Copyright (C) 2008 N. Angelacos for the Alpine Linux project  - GPL2
+# Copyright (C) 2008-2015 N. Angelacos for the Alpine Linux project  - GPL2

 CONF="/etc/syslog.conf"
@@ -25,9 +25,9 @@ syslogd_listfiles() {
 	#		deletes lines that are not filenames with leading "/"
 	#		print it
 	while read a ; do echo "$a"; done < $CONF |\
-		sed -n -e "s/\#.*//" \
+		sed -nE -e "s/\#.*//" \
 			-e "/^[[:space:]]*$/D" \
-			-e "s/[[:space:]]\+/ /g" \
+			-e "s/[[:space:]]+/ /g" \
 			-e "s: -/: /:g" \
 			-e "s/ *; */;/" \
 			-e "/^.*\(auth\)[^ ]* /${skip}D" \
-- 
2.3.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Thu, 12 Mar 2015 08:11:59 +0100

On Wed, 11 Mar 2015 21:28:25 +0000

> +++ b/main/sysklogd/sysklogd.daily

I think you need to change the last line to:

  			-e "/^.*(auth)[^ ]* /${skip}D" \

Test case:

  $ echo "aaabbb" | sed -E -e 's/\(a+\)\(b+\)/\2\1/'
  aaabbb
  $ echo "aaabbb" | sed -E -e 's/(a+)(b+)/\2\1/'
  bbbaaa

-nc

---

---

From: "V.Krishn" <[email-masked]>
Date: Thu, 12 Mar 2015 13:05:17 +0530

> >  # This is a shell script replacement for the sysklogd's logrotate cron
> >  script # and syslogd-listfiles perl script.
> > 

Could someone also run this test after "apk add sed"
and see if they are as expected ?

-- 
Regards.
V.Krishn

---

---

From: Nathan Angelacos <[email-masked]>
Date: Thu, 12 Mar 2015 09:45:17 -0400

>>    			-e "/^.*(auth)[^ ]* /${skip}D" \

Thanks Natanael, you are right.   Looks like you went ahead and fixed my 
patch.  Thanks!

> and see if they are as expected ?

tl;dr - it works as expected with both busybox and gnu sed.

Sysklogd.daily, just printing out /etc/syslog.conf:

# ./sysklogd.daily
/var/log/cron.log
/var/log/daemon.log
/var/log/kern.log
/var/log/lpr.log
/var/log/mail.log
/var/log/user.log
And now with --auth
/var/log/auth.log
/var/log/debug
/var/log/messages
/var/log/syslog

# apk add sed
(1/1) Installing sed (4.2.2-r0)
Executing busybox-1.23.1-r0.trigger
OK: 49 MiB in 41 packages

# ./sysklogd
/var/log/cron.log
/var/log/daemon.log
/var/log/kern.log
/var/log/lpr.log
/var/log/mail.log
/var/log/user.log
And now with --auth
/var/log/auth.log
/var/log/debug
/var/log/messages
/var/log/syslog

-----

# apk del sed
(1/1) Purging sed (4.2.2-r0)
Executing sed-4.2.2-r0.post-deinstall
Executing busybox-1.23.1-r0.trigger
# echo "aaabbb" | sed -E -e 's/\(a+\)\(b+\)/\2\1/'
aaabbb
# echo "aaabbb" | sed -E -e 's/(a+)(b+)/\2\1/'
bbbaaa
# apk add sed
(1/1) Installing sed (4.2.2-r0)
Executing busybox-1.23.1-r0.trigger
OK: 49 MiB in 41 packages
# echo "aaabbb" | sed -E -e 's/\(a+\)\(b+\)/\2\1/'
sed: -e expression #1, char 20: invalid reference \2 on `s' command's RHS
# echo "aaabbb" | sed -E -e 's/(a+)(b+)/\2\1/'
bbbaaa

---