Steal stripcom() from /etc/rc to parse sysmerge.ignore.
authorajacoutot <ajacoutot@openbsd.org>
Mon, 11 Aug 2014 09:03:27 +0000 (09:03 +0000)
committerajacoutot <ajacoutot@openbsd.org>
Mon, 11 Aug 2014 09:03:27 +0000 (09:03 +0000)
usr.sbin/sysmerge/sysmerge.8
usr.sbin/sysmerge/sysmerge.sh

index ce10b07..15df0dc 100644 (file)
@@ -1,4 +1,4 @@
-.\"    $OpenBSD: sysmerge.8,v 1.56 2014/08/11 06:30:39 ajacoutot Exp $
+.\"    $OpenBSD: sysmerge.8,v 1.57 2014/08/11 09:03:27 ajacoutot Exp $
 .\"
 .\" Copyright (c) 2008 Antoine Jacoutot <ajacoutot@openbsd.org>
 .\"
@@ -161,10 +161,8 @@ to
 .Xr ftp 1 .
 .El
 .Pp
-Files and directories can be excluded from comparison
-by listing them in the file
-.Pa /etc/sysmerge.ignore ,
-each entry separated by white space or a new line.
+Files can be excluded from comparison by listing them in
+.Pa /etc/sysmerge.ignore .
 The following files will always be skipped from comparison:
 .Pa /etc/*.db ,
 .Pa /etc/localtime ,
index ddf1949..269dcc9 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/ksh -
 #
-# $OpenBSD: sysmerge.sh,v 1.149 2014/08/10 17:15:18 jmc Exp $
+# $OpenBSD: sysmerge.sh,v 1.150 2014/08/11 09:03:27 ajacoutot Exp $
 #
 # Copyright (c) 2008-2014 Antoine Jacoutot <ajacoutot@openbsd.org>
 # Copyright (c) 1998-2003 Douglas Barton <DougB@FreeBSD.org>
@@ -75,6 +75,20 @@ report() {
        echo "$@" >> ${REPORT}
 }
 
+# from OpenBSD's /etc/rc,v 1.438
+stripcom() {
+       local _file="$1"
+       local _line
+
+       {
+               while read _line ; do
+                       _line=${_line%%#*}              # strip comments
+                       test -z "$_line" && continue
+                       echo $_line
+               done
+       } < $_file
+}
+
 # remove newly created work directory and exit with status 1
 error_rm_wrkdir() {
        (($#)) && echo "!!!! ERROR: $@"
@@ -323,13 +337,11 @@ sm_populate() {
                CF_DIFF=$(diff -q -I "##### " ${TEMPROOT}/${cf} ${DESTDIR}/${cf} 2>/dev/null)
                [[ -z ${CF_DIFF} ]] && IGNORE_FILES="${IGNORE_FILES} ${cf}"
        done
-       if [ -r /etc/sysmerge.ignore ]; then
-               while read i; do \
-                       IGNORE_FILES="${IGNORE_FILES} $(echo ${i} | sed -e 's,\.\.,,g' -e 's,#.*,,g')"
-               done < /etc/sysmerge.ignore
+       if [ -f /etc/sysmerge.ignore ]; then
+               IGNORE_FILES="${IGNORE_FILES} $(stripcom /etc/sysmerge.ignore)"
        fi
        for i in ${IGNORE_FILES}; do
-               rm -rf ${TEMPROOT}/${i};
+               rm -f ${TEMPROOT}/${i}
        done
 }