|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4de5d4 |
# manual_updateChaptersMenu.sh - This function updates chapter menu.
|
|
|
4c79b5 |
#
|
|
|
72c8a5 |
# Copyright (C) 2009-2011 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 |
|
|
|
4de5d4 |
function manual_updateChaptersMenu {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
local ACTION=$1
|
|
|
4c79b5 |
local MENUCHAPTERS=''
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Build menu of chapters. The Index node is not included as other
|
|
|
4c79b5 |
# nodes are. The Index node is defined insde the master texinfo
|
|
|
4c79b5 |
# file (repository.texi). To create the final .info file
|
|
|
4c79b5 |
# correctly, the Index line in the menu should remain, even no
|
|
|
4c79b5 |
# other node exist.
|
|
|
4c79b5 |
if [[ -f ${MANUALS_FILE[2]} ]];then
|
|
|
4c79b5 |
MENUCHAPTERS=$(cat ${MANUALS_FILE[2]} \
|
|
|
4c79b5 |
| egrep -v "^(@(end )?menu$|\* `gettext "Index"`::.*)$")
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Re-defined menu of chapters based on action.
|
|
|
4c79b5 |
case $ACTION in
|
|
|
4c79b5 |
'remove-entry' )
|
|
|
4c79b5 |
# Remove chapter from menu.
|
|
|
4c79b5 |
MENUCHAPTERS=$(echo "$MENUCHAPTERS" \
|
|
|
4c79b5 |
| egrep -v "^\* ${CHAPTERNAME}::[[:print:]]*$")
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
'update-entry' | * )
|
|
|
4c79b5 |
# Update chapter menu using texinfo format.
|
|
|
4c79b5 |
MENUCHAPTERS="$MENUCHAPTERS
|
|
|
4c79b5 |
* $CHAPTERNAME::"
|
|
|
4c79b5 |
;;
|
|
|
4c79b5 |
esac
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Remove opening spaces/tabs and empty line from the menu of
|
|
|
4c79b5 |
# chapters. Empty lines may occur the first time the menu of
|
|
|
4c79b5 |
# chapters is created.
|
|
|
4c79b5 |
MENUCHAPTERS=$(echo "$MENUCHAPTERS" | sed -r 's!^[[:space:]]+!!' \
|
|
|
4c79b5 |
| egrep -v '^[[:space:]]*$')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Organize menu of chapters alphabetically and verify that no
|
|
|
4c79b5 |
# duplicated line be included on the list.
|
|
|
4c79b5 |
MENUCHAPTERS=$(echo "$MENUCHAPTERS" | sort | uniq )
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Give format to final menu output.
|
|
|
4c79b5 |
MENUCHAPTERS="@menu
|
|
|
4c79b5 |
$MENUCHAPTERS
|
|
|
4c79b5 |
* `gettext "Index"`::
|
|
|
4c79b5 |
@end menu"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Strip opening space/tabs from final menu of chapters.
|
|
|
4c79b5 |
MENUCHAPTERS=$(echo "$MENUCHAPTERS" | sed -r 's!^[[:space:]]+!!' \
|
|
|
4c79b5 |
| egrep -v '^[[:space:]]*$')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Dump organized menu of chapters into file.
|
|
|
4c79b5 |
echo "$MENUCHAPTERS" > ${MANUALS_FILE[2]}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|