Blame Scripts/Bash/Functions/Verify/verify_doEnvironment.sh

c29817
#!/bin/bash
c29817
#
c29817
# verify_doEnvironment.sh -- This function outputs a brief description
c29817
# of environment variables used by `centos-art.sh' script.
c29817
#
7cd8e9
# Copyright (C) 2009, 2010 Alain Reguera Delgado
c29817
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
c29817
# 
c29817
# This program is distributed in the hope that it will be useful, but
c29817
# WITHOUT ANY WARRANTY; without even the implied warranty of
c29817
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c29817
# General Public License for more details.
c29817
#
c29817
# You should have received a copy of the GNU General Public License
c29817
# along with this program; if not, write to the Free Software
c29817
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
c29817
# USA.
c29817
# 
c29817
# ----------------------------------------------------------------------
c29817
# $Id$
c29817
# ----------------------------------------------------------------------
c29817
c29817
function verify_doEnvironment {
c29817
c29817
    local -a VARS
c29817
    local -a INFO
c29817
    local COUNT=0
c29817
c29817
    # Define name of environment variables used by centos-art.sh
c29817
    # script.
c29817
    VARS[0]='EDITOR'
c29817
    VARS[1]='TZ'
c29817
    VARS[2]='TEXTDOMAIN'
c29817
    VARS[3]='TEXTDOMAINDIR'
c29817
    VARS[4]='LANG'
c29817
c29817
    # Define description of environment variables.
c29817
    INFO[0]="`gettext "Default text editor"`"
c29817
    INFO[1]="`gettext "Default time zone representation"`"
c29817
    INFO[2]="`gettext "Default domain used to retrieve translated messages"`"
c29817
    INFO[3]="`gettext "Default directory used to retrive translated messages"`"
c29817
    INFO[4]="`gettext "Default locale information"`"
c29817
4b8e06
    # Define short options we want to support.
4b8e06
    ARGSS=""
4b8e06
4b8e06
    # Define long options we want to support.
4b8e06
    ARGSL="filter:"
4b8e06
4b8e06
    # Parse arguments using getopt(1) command parser.
4b8e06
    cli_doParseArguments
4b8e06
4b8e06
    # Reset positional parameters using output from (getopt) argument
4b8e06
    # parser.
4b8e06
    eval set -- "$ARGUMENTS"
4b8e06
4b8e06
    # Define action to take for each option passed.
4b8e06
    while true; do
4b8e06
        case "$1" in
4b8e06
            --filter )
4b8e06
               REGEX="$2" 
4b8e06
               shift 2
4b8e06
               ;;
4b8e06
            * )
4b8e06
                break
4b8e06
        esac
4b8e06
    done
4b8e06
c29817
    until [[ $COUNT -eq ${#VARS[*]} ]];do
c29817
4b8e06
        # Let user to reduce output using regular expression as
c29817
        # reference.
c29817
        if [[ ${VARS[$COUNT]} =~ $REGEX ]];then
c29817
c29817
            # Output list of environment variables using indirect
c29817
            # expansion (what a beautiful feature!) to output variable
c29817
            # value.
c29817
            cli_printMessage "${INFO[$COUNT]}:"
c29817
            cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" 'AsResponseLine'
c29817
c29817
        fi
c29817
c29817
        # Increment counter.
c29817
        COUNT=$(($COUNT + 1))
c29817
c29817
    done
c29817
c29817
}