From: millert Date: Sun, 5 Mar 2000 16:55:22 +0000 (+0000) Subject: Adda a stripcom function to strip comments (and leading whitespace, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5420764bdf6bf6da1d1bef15728427c3dc6f572c;p=openbsd Adda a stripcom function to strip comments (and leading whitespace, depending on IFS). This replaces the ed and sed code previously used to do this. --- diff --git a/etc/rc b/etc/rc index 2f894fe4e70..26792c6db77 100644 --- a/etc/rc +++ b/etc/rc @@ -1,10 +1,29 @@ -# $OpenBSD: rc,v 1.130 2000/02/28 17:28:35 itojun Exp $ +# $OpenBSD: rc,v 1.131 2000/03/05 16:55:22 millert Exp $ # System startup script run by init on autoboot # or after single-user. # Output and error are redirected to console by init, # and the console is the controlling terminal. +# Subroutines (have to come first). + +# Strip comments (and leading/trailing whitespace if IFS is set) +# from a file and spew to stdout +stripcom() { + local _file="$1" + local _line + + { + while read _line ; do + _line=${_line%%#*} # strip comments + test -z "$_line" && continue + echo $_line + done + } < $_file +} + +# End subroutines + stty status '^T' # Set shell to ignore SIGINT (2), but not children; @@ -108,14 +127,7 @@ fi if [ -f /etc/sysctl.conf ]; then ( # delete comments and blank lines - # we use ed here because /usr may not be mounted yet. - set -- ` - ed -s /etc/sysctl.conf < $T echo "" >> $T