Blame Scripts/Bash/Functions/Render/render_getConfigOption.sh
|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# render_getConfigOption.sh -- This function standardizes the
|
|
|
878a2b |
|
|
|
878a2b |
# definitions.
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
#
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function render_getConfigOption {
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local ACTION="$1"
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local FIELD="$2"
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
local OPTION=''
|
|
|
878a2b |
|
|
|
878a2b |
# Check action string. The action string must be present in order
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ "$ACTION" == '' ]];then
|
|
|
878a2b |
cli_printMessage "`gettext "There is no action string to work with."`" --as-error-line
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then
|
|
|
878a2b |
cli_printMessage "`gettext "The field definition is not valid."`" --as-error-line
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
OPTION=$(echo -n "$ACTION" | cut -d: -f${FIELD})
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
OPTION=$(echo -n "${OPTION}" \
|
|
|
878a2b |
| sed -r 's!^ *!!g' \
|
|
|
878a2b |
| sed -r 's!( |,|;) *! !g' \
|
|
|
878a2b |
| sed -r 's! *$!!g')
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
# only if it is not an empty value. Do not use `echo' or `printf'
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
|
|
|
878a2b |
if [[ $OPTION != '' ]];then
|
|
|
878a2b |
cli_printMessage "$OPTION" --as-stdout-line
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
}
|