|
|
eb0e14 |
#!/bin/bash
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# render_doIdentityImageDm.sh -- This function standardize the way of
|
|
|
eb0e14 |
# retrive option values from pre-rendering configuration files. Use
|
|
|
eb0e14 |
# this function whenever you need to retrive option values from
|
|
|
eb0e14 |
# pre-rendering configuration script.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# Usage:
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# VAR=$(render_getConfOption "ACTION" "FIELD")
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# Where:
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# VAR is the name of the variable you want to store the option
|
|
|
eb0e14 |
# value retrived from your specification, using
|
|
|
eb0e14 |
# render_getConfOption's ACTION and FIELD arguments. If there is
|
|
|
eb0e14 |
# no variable assignment, the function outputs the option value
|
|
|
eb0e14 |
# to standard output without trailing newline.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# ACTION is the string definition set in the pre-rendering
|
|
|
eb0e14 |
# configuration script holding the action name and its options
|
|
|
eb0e14 |
# fields.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# FIELD is field number in the action string you want to
|
|
|
eb0e14 |
# retrive option from. By default options start from third field
|
|
|
eb0e14 |
# on. The first field is reserved for the action type (i.e.,
|
|
|
eb0e14 |
# BASE, POST, LAST), and the second field is reserved for the
|
|
|
eb0e14 |
# action itself (e.g., renderImage, renderFormats, etc.). Note
|
|
|
eb0e14 |
# that this convenction can be altered if the action string has
|
|
|
eb0e14 |
# been modified (e.g., you stript the BASE field from action
|
|
|
eb0e14 |
# string) and passed the modified action string to another
|
|
|
eb0e14 |
# function for processing.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# Copyright (C) 2009-2010 Alain Reguera Delgado
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# This program is free software; you can redistribute it and/or modify
|
|
|
eb0e14 |
# it under the terms of the GNU General Public License as published by
|
|
|
eb0e14 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
eb0e14 |
# (at your option) any later version.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# This program is distributed in the hope that it will be useful, but
|
|
|
eb0e14 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
eb0e14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
eb0e14 |
# General Public License for more details.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# You should have received a copy of the GNU General Public License
|
|
|
eb0e14 |
# along with this program; if not, write to the Free Software
|
|
|
eb0e14 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
eb0e14 |
# USA.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# ----------------------------------------------------------------------
|
|
|
eb0e14 |
# $Id$
|
|
|
eb0e14 |
# ----------------------------------------------------------------------
|
|
|
eb0e14 |
|
|
|
eb0e14 |
function render_getConfOption {
|
|
|
eb0e14 |
|
|
|
eb0e14 |
local ACTION="$1"
|
|
|
eb0e14 |
local FIELD="$2"
|
|
|
eb0e14 |
local VALUE=''
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Check action value. The action's value must be present in order
|
|
|
eb0e14 |
# for this function to work. It provides the string needed to
|
|
|
eb0e14 |
# retrive options from.
|
|
|
eb0e14 |
if [[ "$ACTION" == '' ]];then
|
|
|
eb0e14 |
cli_printMessage "`gettext "There is no action to work with."`"
|
|
|
eb0e14 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
eb0e14 |
fi
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Check field value. The field's value must match the cut's
|
|
|
eb0e14 |
# command specification of its -f option.
|
|
|
eb0e14 |
if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then
|
|
|
eb0e14 |
cli_printMessage "`gettext "The field specified is not valid."`"
|
|
|
eb0e14 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
eb0e14 |
fi
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Get option from pre-rendering configuration action definition.
|
|
|
eb0e14 |
VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD})
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Sanitate option value passed from pre-rendering configuration
|
|
|
eb0e14 |
# action definition.
|
|
|
eb0e14 |
VALUE=$(echo -n "${VALUE}" \
|
|
|
eb0e14 |
| sed -r 's!^ *!!g' \
|
|
|
eb0e14 |
| sed -r 's!( |,|;) *! !g' \
|
|
|
eb0e14 |
| sed -r 's! *$!!g')
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Output option value without trailing newline.
|
|
|
eb0e14 |
echo -n "$VALUE"
|
|
|
eb0e14 |
|
|
|
eb0e14 |
}
|