|
Alain Reguera Delgado |
8f60cb |
#!/bin/bash
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# render_getConfigOption.sh -- This function standardizes the
|
|
Alain Reguera Delgado |
8f60cb |
# configuration fields are retrived from some action-specific
|
|
Alain Reguera Delgado |
8f60cb |
# definitions.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# Copyright (C) 2009-2013 The CentOS Project
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
8f60cb |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
8f60cb |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
8f60cb |
# your option) any later version.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
8f60cb |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
8f60cb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
8f60cb |
# General Public License for more details.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
8f60cb |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
8f60cb |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
# $Id$
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
function render_getConfigOption {
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Initialize action string.
|
|
Alain Reguera Delgado |
8f60cb |
local ACTION="$1"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Initialize field definition.
|
|
Alain Reguera Delgado |
8f60cb |
local FIELD="$2"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Initialize configuration options.
|
|
Alain Reguera Delgado |
8f60cb |
local OPTION=''
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Check action string. The action string must be present in order
|
|
Alain Reguera Delgado |
8f60cb |
# for this function to work. It provides the information needed to
|
|
Alain Reguera Delgado |
8f60cb |
# retrive configurantion options from.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ "$ACTION" == '' ]];then
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "`gettext "There is no action string to work with."`" --as-error-line
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Check field definition. The field definition must match any of
|
|
Alain Reguera Delgado |
8f60cb |
# the formats specified by the `-f' option of `cut' command.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "`gettext "The field definition is not valid."`" --as-error-line
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Get configuration option from action string.
|
|
Alain Reguera Delgado |
8f60cb |
OPTION=$(echo -n "$ACTION" | cut -d: -f${FIELD})
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Sanitate configuration option retrived from action string.
|
|
Alain Reguera Delgado |
8f60cb |
OPTION=$(echo -n "${OPTION}" \
|
|
Alain Reguera Delgado |
8f60cb |
| sed -r 's!^ *!!g' \
|
|
Alain Reguera Delgado |
8f60cb |
| sed -r 's!( |,|;) *! !g' \
|
|
Alain Reguera Delgado |
8f60cb |
| sed -r 's! *$!!g')
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Print out the configuration option retrived from action string,
|
|
Alain Reguera Delgado |
8f60cb |
# only if it is not an empty value. Do not use `echo' or `printf'
|
|
Alain Reguera Delgado |
8f60cb |
# built-in commands here. Use the `cli_printMessage' functionality
|
|
Alain Reguera Delgado |
8f60cb |
# instead. This is required in order to reverse the apostrophe
|
|
Alain Reguera Delgado |
8f60cb |
# codification accomplished when options were retrived from
|
|
Alain Reguera Delgado |
8f60cb |
# command-line (cli_parseArgumentsReDef) in the argument of
|
|
Alain Reguera Delgado |
8f60cb |
# options like `--post-rendition' and `--last-rendition'.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ $OPTION != '' ]];then
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "$OPTION" --as-stdout-line
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
}
|