|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# help_searchIndex.sh -- This function does an index search inside the
|
|
|
4c79b5 |
# info document.
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
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.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c79b5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# You should have received a copy of the GNU General Public License
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function help_searchIndex {
|
|
|
4c79b5 |
|
|
|
d8a742 |
# Define search pattern format.
|
|
|
4c79b5 |
local PATTERN='^[[:alnum:],]+$'
|
|
|
4c79b5 |
|
|
|
d8a742 |
# Define default search string.
|
|
|
d8a742 |
local SEARCH=''
|
|
|
d8a742 |
|
|
|
d8a742 |
# Define short options we want to support.
|
|
|
572bab |
local ARGSS=""
|
|
|
d8a742 |
|
|
|
d8a742 |
# Define long options we want to support.
|
|
|
572bab |
local ARGSL="filter:"
|
|
|
d8a742 |
|
|
|
d8a742 |
# Parse arguments using getopt(1) command parser.
|
|
|
d8a742 |
cli_doParseArguments
|
|
|
d8a742 |
|
|
|
d8a742 |
# reset positional parameters using output from (getopt) argument
|
|
|
d8a742 |
# parser.
|
|
|
d8a742 |
eval set -- "$ARGUMENTS"
|
|
|
d8a742 |
|
|
|
d8a742 |
# Define action to take for each option passed.
|
|
|
d8a742 |
while true; do
|
|
|
d8a742 |
case "$1" in
|
|
|
d8a742 |
--filter )
|
|
|
d8a742 |
SEARCH="$2"
|
|
|
d8a742 |
shift 2
|
|
|
d8a742 |
;;
|
|
|
d8a742 |
* )
|
|
|
d8a742 |
break
|
|
|
d8a742 |
esac
|
|
|
d8a742 |
done
|
|
|
d8a742 |
|
|
|
d8a742 |
# Re-define default SEARCH value. If the search string is not
|
|
|
d8a742 |
# provided as `--filter' argument, ask user to provide one.
|
|
|
d8a742 |
if [[ ! $SEARCH =~ $PATTERN ]];then
|
|
|
d8a742 |
cli_printMessage "`gettext "Enter the search pattern"`" "AsRequestLine"
|
|
|
d8a742 |
read SEARCH
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
d8a742 |
# Validate search string using search pattern.
|
|
|
d8a742 |
if [[ ! "$SEARCH" =~ $PATTERN ]];then
|
|
|
d8a742 |
cli_printMessage "`gettext "The search pattern is not valid."`" 'AsErrorLine'
|
|
|
1f1b3c |
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
d8a742 |
# Perform index search inside documentation info file.
|
|
|
d8a742 |
/usr/bin/info --index-search="$SEARCH" --file=${MANUALS_FILE[4]}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|