Blame Scripts/Bash/Functions/cli_doParseArguments.sh

b7b189
#!/bin/bash
b7b189
#
f4da7e
# cli_doParseArguments.sh -- This function redefines arguments
f4da7e
# (ARGUMENTS) global variable using getopt(1) output.
b7b189
#
073c6f
# Copyright (C) 2009-2011 Alain Reguera Delgado
b7b189
# 
b7b189
# This program is free software; you can redistribute it and/or
b7b189
# modify it under the terms of the GNU General Public License as
b7b189
# published by the Free Software Foundation; either version 2 of the
b7b189
# License, or (at your option) any later version.
b7b189
# 
b7b189
# This program is distributed in the hope that it will be useful, but
b7b189
# WITHOUT ANY WARRANTY; without even the implied warranty of
b7b189
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b7b189
# General Public License for more details.
b7b189
#
b7b189
# You should have received a copy of the GNU General Public License
b7b189
# along with this program; if not, write to the Free Software
b7b189
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
b7b189
# USA.
b7b189
# 
b7b189
# ----------------------------------------------------------------------
9aebad
# $Id$
b7b189
# ----------------------------------------------------------------------
b7b189
b7b189
function cli_doParseArguments {
b7b189
b7b189
    # Reset positional parameters using optional arguments.
b7b189
    eval set -- "$ARGUMENTS"
b7b189
b7b189
    # Parse optional arguments using getopt.
b7b189
    ARGUMENTS=$(getopt -o "$ARGSS" -l "$ARGSL" -n $CLINAME -- "$@")
b7b189
b7b189
    # Be sure getout parsed arguments successfully.
b7b189
    if [[ $? != 0 ]]; then 
b7b189
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
b7b189
    fi
b7b189
b7b189
}