=================================================================== RCS file: /cvs/openbsd/sxxu/Attic/install.sxxu,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- openbsd/sxxu/Attic/install.sxxu 2010/04/23 00:01:30 1.16 +++ openbsd/sxxu/Attic/install.sxxu 2010/04/23 22:14:22 1.17 @@ -1,5 +1,5 @@ #!/bin/ksh - -# $Id: install.sxxu,v 1.16 2010/04/22 23:01:30 andrew Exp $ +# $Id: install.sxxu,v 1.17 2010/04/23 21:14:22 andrew Exp $ # Copyright (c) 2010 Andrew Fresh # @@ -32,22 +32,6 @@ echo 'See /var/log/install.log for install messages.' } -# 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 -} - - process_roles() { local _oldpwd="${PWD}" @@ -61,11 +45,13 @@ unset _roles set -A _roles local _role - stripcom roles | while read _role; do + while read _role; do if [ -n "${_role}" ]; then + _line=${_line%%#*} # strip comments + test -z "$_line" && continue _roles[${#_roles[@]}]="$_role" fi - done + done < roles for _role in "${_roles[@]}"; do apply_role "$_role" @@ -80,13 +66,15 @@ echo ' ==> Setting PKG_PATH' local _line - stripcom pkg_path | while read _line; do + while read _line; do + _line=${_line%%#*} # strip comments + test -z "$_line" && continue if [ -z "${PKG_PATH}" ]; then PKG_PATH="$_line" else PKG_PATH="${PKG_PATH}:${_line}" fi - done + done < pkg_path PKG_PATH=`eval echo $PKG_PATH` } @@ -101,10 +89,12 @@ echo " ==> Running $_cmd $_args" local _line - stripcom "${_f}" | while read _line; do + while read _line; do + _line=${_line%%#*} # strip comments + test -z "$_line" && continue echo " => ${_cmd} ${_args} ${_line}" eval ${_cmd} ${_args} ${_line} - done + done < "${_f}" done }