Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add a collapse_backslash_newline function to rc.subr.



details:   https://anonhg.NetBSD.org/src/rev/ed2affc576ae
branches:  trunk
changeset: 757839:ed2affc576ae
user:      apb <apb%NetBSD.org@localhost>
date:      Sun Sep 26 18:37:14 2010 +0000

description:
Add a collapse_backslash_newline function to rc.subr.

diffstat:

 etc/rc.subr              |  25 +++++++++++++++++++++++--
 share/man/man8/rc.subr.8 |   8 +++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diffs (67 lines):

diff -r bbcdabd7db19 -r ed2affc576ae etc/rc.subr
--- a/etc/rc.subr       Sun Sep 26 02:26:59 2010 +0000
+++ b/etc/rc.subr       Sun Sep 26 18:37:14 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.85 2010/06/08 18:04:17 christos Exp $
+# $NetBSD: rc.subr,v 1.86 2010/09/26 18:37:14 apb Exp $
 #
 # Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1194,6 +1194,27 @@
                echo "terminated with signal $(expr $1 - 128)"
        fi
 }
-       
+
+#
+# collapse_backslash_newline
+#      Copy input to output, collapsing <backslash><newline>
+#      to nothing, but leaving other backslashes alone.
+#
+collapse_backslash_newline()
+{
+       local line
+       while read -r line ; do
+               case "$line" in
+               *\\)
+                       # print it, without the backslash or newline
+                       printf "%s" "${line%?}"
+                       ;;
+               *)
+                       # print it, with a newline
+                       printf "%s\n" "${line}"
+                       ;;
+               esac
+       done
+}
 
 _rc_subr_loaded=:
diff -r bbcdabd7db19 -r ed2affc576ae share/man/man8/rc.subr.8
--- a/share/man/man8/rc.subr.8  Sun Sep 26 02:26:59 2010 +0000
+++ b/share/man/man8/rc.subr.8  Sun Sep 26 18:37:14 2010 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: rc.subr.8,v 1.26 2010/03/15 19:00:20 jmmv Exp $
+.\"    $NetBSD: rc.subr.8,v 1.27 2010/09/26 18:37:15 apb Exp $
 .\"
 .\" Copyright (c) 2002-2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -46,6 +46,8 @@
 .It
 .Ic check_process Ar procname Op Ar interpreter
 .It
+.Ic collapse_backslash_newline
+.It
 .Ic err Ar exitval Ar message
 .It
 .Ic load_rc_config Ar command
@@ -208,6 +210,10 @@
 .Ar interpreter
 is handled as per
 .Ic check_pidfile .
+.It Ic collapse_backslash_newline
+Copy input to output, collapsing
+.Ao backslash Ac Ns Ao newline Ac
+to nothing, but leaving other backslashes alone.
 .It Ic err Ar exitval Ar message
 Display an error message to
 .Em stderr ,



Home | Main Index | Thread Index | Old Index