Blame Scripts/Functions/cli_unsetFunctions.sh

ffe595
#!/bin/bash
ffe595
#
ffe595
# cli_unsetFunctions.sh -- This function unsets funtionalities from
ffe595
# `centos-art.sh' script execution evironment.
ffe595
#
ffe595
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
ffe595
#
ffe595
# This program is free software; you can redistribute it and/or modify
ffe595
# it under the terms of the GNU General Public License as published by
ffe595
# the Free Software Foundation; either version 2 of the License, or (at
ffe595
# your option) any later version.
ffe595
#
ffe595
# This program is distributed in the hope that it will be useful, but
ffe595
# WITHOUT ANY WARRANTY; without even the implied warranty of
ffe595
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ffe595
# General Public License for more details.
ffe595
#
ffe595
# You should have received a copy of the GNU General Public License
ffe595
# along with this program; if not, write to the Free Software
ffe595
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
ffe595
#
ffe595
# ----------------------------------------------------------------------
ffe595
# $Id$
ffe595
# ----------------------------------------------------------------------
ffe595
ffe595
function cli_unsetFunctions {
ffe595
ffe595
    # Define source location where function files are placed in.
ffe595
    local LOCATION=$1
ffe595
ffe595
    # Define suffix used to retrive function files.
ffe595
    local SUFFIX=$2
ffe595
ffe595
    # Verify suffix value used to retrive function files. Assuming no
ffe595
    # suffix value is passed as second argument to this function, use
5a5b08
    # the function name value (CLI_FUNCNAME) as default value.
ffe595
    if [[ $SUFFIX == '' ]];then
5a5b08
        SUFFIX=$CLI_FUNCNAME
ffe595
    fi
ffe595
ffe595
    # Define list of backend-specific functionalities. This is the
ffe595
    # list of function definitions previously exported by
ffe595
    # `cli_exportFunctions'.  Be sure to limit the list to function
ffe595
    # names that start with the suffix specified only.
ffe595
    local FUNCDEF=''
204d67
    local FUNCDEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${SUFFIX}")
ffe595
ffe595
    # Unset function names from current execution environment.
ffe595
    for FUNCDEF in $FUNCDEFS;do
ffe595
        unset -f $FUNCDEF
ffe595
    done
ffe595
ffe595
}