#---------------------------------------------------------------------------- # /var/install/include/configlib - library for eisfair scripts # # Copyright (c) 2005 Frank Meyer # # Creation: 24.05.2005 max # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # interface description #---------------------------------------------------------------------------- # # printvar() print a config variable # #---------------------------------------------------------------------------- #============================================================================ # only include this file once #============================================================================ if [ "$_CONFIGLIB" != "true" ] then _CONFIGLIB='true' # # printvar # ======== # # prints config variables and comments with specific indenting # # # Parameters: $1 name of variable # e.g. "FOO_ARRAY_2_VARIABLE" # $2 comment # e.g. "an important option" # # Output: variable entry line for an eisfair config-file # e.g. "FOO_ARRAY_2_VARIABLE="myvalue" # an important option" # # fixed spaces string - 60 character long (fast method) _configlib_spacestr=" " _configlib_commentpos=37 printvar() { _printvar_varname=$1 if [ "$2" == "" ] then _printvar_comment='' else _printvar_comment=" # $2" fi if [ "$_printvar_varname" == "" ] then echo "`echo "$_configlib_spacestr" | head -c$_configlib_commentpos`$_printvar_comment" else _printvar_varlen=${#_printvar_varname} eval _printvar_value='$'$_printvar_varname _printvar_vallen=${#_printvar_value} HK="'" if echo $_printvar_value | grep -q "'" then HK='"' fi _printvar_strlen=`expr $_configlib_commentpos - 3 - $_printvar_varlen - $_printvar_vallen` if [ $_printvar_strlen -lt 0 ] then echo "$_printvar_varname=$HK$_printvar_value$HK" if [ "$_printvar_comment" != "" ] then echo "`echo "$_configlib_spacestr" | head -c$_configlib_commentpos`$_printvar_comment" fi else echo "$_printvar_varname=$HK$_printvar_value$HK`echo "$_configlib_spacestr" | head -c$_printvar_strlen`$_printvar_comment" fi fi } fi