Blame Scripts/Functions/Help/help_getEntries.sh

e82789
#!/bin/bash
e82789
#
e82789
# help_getEntries.sh -- This function interpretes non-option
e82789
# arguments passed to `help' functionality through the command-line
e82789
# and redefines array variables related to documentation entries.
e82789
#
e82789
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
e82789
#
e82789
# This program is free software; you can redistribute it and/or modify
e82789
# it under the terms of the GNU General Public License as published by
e82789
# the Free Software Foundation; either version 2 of the License, or (at
e82789
# your option) any later version.
e82789
#
e82789
# This program is distributed in the hope that it will be useful, but
e82789
# WITHOUT ANY WARRANTY; without even the implied warranty of
e82789
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e82789
# General Public License for more details.
e82789
#
e82789
# You should have received a copy of the GNU General Public License
e82789
# along with this program; if not, write to the Free Software
e82789
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e82789
#
e82789
# ----------------------------------------------------------------------
e82789
# $Id$
e82789
# ----------------------------------------------------------------------
e82789
e82789
function help_getEntries {
e82789
e82789
    local DOCENTRY=''
e82789
e82789
    # Redefine positional parameters using ARGUMENTS. At this point,
e82789
    # option arguments have been removed from ARGUMENTS variable and
e82789
    # only non-option arguments remain in it. 
e82789
    eval set -- "$ARGUMENTS"
e82789
e82789
    # Build manual array to store information required to process
e82789
    # documentation entries (e.g., manual name, chapter name and
e82789
    # section name.) At this point all option arguments have been
e82789
    # removed from positional paramters so we can use the remaining
e82789
    # non-option arguments as reference to retrive documentation
e82789
    # entries. Documentation entries passed as non-opiton arguments
e82789
    # must have the `MANUAL:CHAPTER:SECTION' format in order to be
e82789
    # processed correctly here.
e82789
    for DOCENTRY in $@;do
e82789
e82789
        # Manual self name.
e82789
        MANUAL_SLFN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
e82789
            $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $1 }') -f \
e82789
            | tr '[:upper:]' '[:lower:]')
e82789
e82789
        # Manual directory name.
e82789
        MANUAL_DIRN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
e82789
            $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $1 }') -f \
e82789
            | tr '[:lower:]' '[:upper:]')
e82789
e82789
        # Manual chapter name.
e82789
        MANUAL_CHAN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
e82789
            $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $2 }') -d )
e82789
e82789
        # Manual section name.
e82789
        MANUAL_SECN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
e82789
            $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $3 }') -f )
e82789
e82789
        # Increment counting of non-option arguments.
e82789
        MANUAL_DOCENTRY_COUNT=$(($MANUAL_DOCENTRY_COUNT + 1))
e82789
e82789
    done
e82789
e82789
}