diff --git a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh index 4cb7e79..0259f96 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityGroupByType.sh @@ -87,7 +87,7 @@ function render_doIdentityGroupByType { # Sanitate file types passed from render.conf.sh pre-rendition # configuration script. - FORMATS=$(render_getConfOption "$FORMATS" '2-') + FORMATS=$(render_getIdentityConfigOption "$FORMATS" '2-') # Check file types passed from render.conf.sh pre-rendition # configuration script. diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh index f9670bc..3d8b7ec 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageDm.sh @@ -57,7 +57,7 @@ function render_doIdentityImageDm { # Get display manager passed from render.conf.sh pre-rendition # configuration script. - DM=$(render_getConfOption "$1" '2') + DM=$(render_getIdentityConfigOption "$1" '2') # Sanitate display manager possible values and define absolute # path to display manager design models (i.e., the place where @@ -78,7 +78,7 @@ function render_doIdentityImageDm { # Get screen resolutions passed from render.conf.sh pre-rendition # configuration script. - RESOLUTIONS=$(render_getConfOption "$1" '3') + RESOLUTIONS=$(render_getIdentityConfigOption "$1" '3') # Check sanitated screen resolutions. if [[ "$RESOLUTIONS" == '' ]];then diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh index 683fbcd..77ccffc 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageFormats.sh @@ -33,7 +33,7 @@ function render_doIdentityImageFormats { local FILE="$1" # Get image formats. - local FORMATS=$(render_getConfOption "$2" '2-') + local FORMATS=$(render_getIdentityConfigOption "$2" '2-') # Check base file existence. if [[ -f ${FILE}.png ]];then diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh index 7e33d19..8b349ed 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageGrub.sh @@ -37,7 +37,7 @@ function render_doIdentityImageGrub { # configuration script. These options are applied to pnmremap when # doing color reduction, so any option available for pnmremap # command can be passed to renderSyslinux functionality. - OPTIONS=$(render_getConfOption "$ACTION" '2-') + OPTIONS=$(render_getIdentityConfigOption "$ACTION" '2-') # Re-define 16 colors images default file name prefix using # options as reference. This is useful to differenciate final diff --git a/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh b/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh index 70bf584..328b0bb 100755 --- a/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh @@ -37,7 +37,7 @@ function render_doIdentityImageSyslinux { # configuration script. These options are applied to pnmremap when # doing color reduction, so any option available for pnmremap # command can be passed to renderSyslinux functionality. - OPTIONS=$(render_getConfOption "$ACTION" '2-') + OPTIONS=$(render_getIdentityConfigOption "$ACTION" '2-') # Check options passed to action. This is required in order to # aviod using options used already in this script. For example diff --git a/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh b/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh index e94dc14..5d0adce 100644 --- a/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh +++ b/Scripts/Bash/Functions/Render/render_doIdentityTextFormats.sh @@ -33,7 +33,7 @@ function render_doIdentityTextFormats { local TMPFILE=$(cli_getTemporalFile "${FILE}") # Get action to do over text file. - local OPTIONS=$(render_getConfOption "$2" '2-') + local OPTIONS=$(render_getIdentityConfigOption "$2" '2-') # Remove some fmt's options. As we are applying fmt's options to a # file directly, there are some options like --version and --help diff --git a/Scripts/Bash/Functions/Render/render_getConfOption.sh b/Scripts/Bash/Functions/Render/render_getConfOption.sh deleted file mode 100755 index a99378c..0000000 --- a/Scripts/Bash/Functions/Render/render_getConfOption.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# -# render_getConfOption.sh -- This function standardizes the way action -# values are retrived from pre-rendition configuration files. Use -# this function whenever you need to retrive action values from -# pre-rendition configuration script. -# -# Usage: VAR=$(render_getConfOption "ACTION" "FIELD") -# -# VAR is the name of the variable where we store the option named -# returned by render_getConfOption. -# -# ACTION is the string definition set in the pre-rendition -# configuration script that holds the action name and its options -# fields. -# -# FIELD is the field number in the action string we want to retrive -# option from. By default options start from third field on. The first -# field is reserved for the action type (i.e., BASE, POST or LAST), and -# the second field is reserved for the action itself (e.g., -# renderImage, renderFormats, etc.). Note that this convenction can be -# altered if the action string has been modified (e.g., you stript the -# BASE field from action string) and passed the modified action string -# to another function for processing. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_getConfOption { - - local ACTION="$1" - local FIELD="$2" - local VALUE='' - - # Check action value. The action's value must be present in order - # for this function to work. It provides the string needed to - # retrive options from. - if [[ "$ACTION" == '' ]];then - cli_printMessage "`gettext "There is no action to work with."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Check field value. The field's value must match the cut's - # command specification of its -f option. - if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then - cli_printMessage "`gettext "The field specified is not valid."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Get option from pre-rendition configuration action definition. - VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) - - # Sanitate action value passed from pre-rendition configuration - # action definition. - VALUE=$(echo -n "${VALUE}" \ - | sed -r 's!^ *!!g' \ - | sed -r 's!( |,|;) *! !g' \ - | sed -r 's! *$!!g') - - # Output action value without trailing newline. - echo -n "$VALUE" - -} diff --git a/Scripts/Bash/Functions/Render/render_getIdentityConfig.sh b/Scripts/Bash/Functions/Render/render_getIdentityConfig.sh index 5bdbf99..6576802 100755 --- a/Scripts/Bash/Functions/Render/render_getIdentityConfig.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityConfig.sh @@ -38,19 +38,19 @@ function render_getIdentityConfig { # Define base-rendition actions. if [[ $ACTION =~ '^BASE:render(Text|Image)$' ]];then - ACTION=$(render_getConfOption "$ACTION" '2-') + ACTION=$(render_getIdentityConfigOption "$ACTION" '2-') BASEACTIONS[$BASECOUNT]="$ACTION" BASECOUNT=$(($BASECOUNT + 1)) # Define post-rendition actions. elif [[ $ACTION =~ '^POST:' ]];then - ACTION=$(render_getConfOption "$ACTION" '2-') + ACTION=$(render_getIdentityConfigOption "$ACTION" '2-') POSTACTIONS[$POSTCOUNT]="$ACTION" POSTCOUNT=$(($POSTCOUNT + 1)) # Define last-rendition actions. elif [[ $ACTION =~ '^LAST:' ]];then - ACTION=$(render_getConfOption "$ACTION" '2-') + ACTION=$(render_getIdentityConfigOption "$ACTION" '2-') LASTACTIONS[$LASTCOUNT]="$ACTION" LASTCOUNT=$(($LASTCOUNT + 1)) fi diff --git a/Scripts/Bash/Functions/Render/render_getIdentityConfigOption.sh b/Scripts/Bash/Functions/Render/render_getIdentityConfigOption.sh new file mode 100755 index 0000000..3e46d83 --- /dev/null +++ b/Scripts/Bash/Functions/Render/render_getIdentityConfigOption.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# render_getIdentityConfigOption.sh -- This function standardizes the way action +# values are retrived from pre-rendition configuration files. Use +# this function whenever you need to retrive action values from +# pre-rendition configuration script. +# +# Usage: VAR=$(render_getIdentityConfigOption "ACTION" "FIELD") +# +# VAR is the name of the variable where we store the option named +# returned by render_getIdentityConfigOption. +# +# ACTION is the string definition set in the pre-rendition +# configuration script that holds the action name and its options +# fields. +# +# FIELD is the field number in the action string we want to retrive +# option from. By default options start from third field on. The first +# field is reserved for the action type (i.e., BASE, POST or LAST), and +# the second field is reserved for the action itself (e.g., +# renderImage, renderFormats, etc.). Note that this convenction can be +# altered if the action string has been modified (e.g., you stript the +# BASE field from action string) and passed the modified action string +# to another function for processing. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_getIdentityConfigOption { + + local ACTION="$1" + local FIELD="$2" + local VALUE='' + + # Check action value. The action's value must be present in order + # for this function to work. It provides the string needed to + # retrive options from. + if [[ "$ACTION" == '' ]];then + cli_printMessage "`gettext "There is no action to work with."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Check field value. The field's value must match the cut's + # command specification of its -f option. + if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then + cli_printMessage "`gettext "The field specified is not valid."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Get option from pre-rendition configuration action definition. + VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD}) + + # Sanitate action value passed from pre-rendition configuration + # action definition. + VALUE=$(echo -n "${VALUE}" \ + | sed -r 's!^ *!!g' \ + | sed -r 's!( |,|;) *! !g' \ + | sed -r 's! *$!!g') + + # Output action value without trailing newline. + echo -n "$VALUE" + +}