|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
0211a4 |
# help_updateMenu.sh -- This function updates menu lines inside
|
|
|
4c79b5 |
# texinfo chapters. If this function is called with the
|
|
|
4c79b5 |
# 'remove-entry' string as first argument, then the menu line related
|
|
|
4c79b5 |
# to the entry being processed is removed. If this function is called
|
|
|
4c79b5 |
# with the 'update-entry' string as first argument, then the menu line
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# argument is passed to this function, the 'update-entry' action is
|
|
|
4c79b5 |
# assumed.
|
|
|
4c79b5 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
|
|
|
dcd347 |
|
|
|
dcd347 |
|
|
|
fa95b1 |
#
|
|
|
74a058 |
|
|
|
74a058 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
0211a4 |
function help_updateMenu {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
local ACTION="$1"
|
|
|
4c79b5 |
|
|
|
4da029 |
|
|
|
4c79b5 |
|
|
|
a3b457 |
local MENUNODE=$(echo "$ENTRY" | cut -d / -f8- | tr '/' ' ' \
|
|
|
4da029 |
| sed 's!\.texi$!!')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Give format to menu line using texinfo style.
|
|
|
4da029 |
local MENULINE="* ${MANUAL_CHAPTER_NAME} $MENUNODE::"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
7f7f8f |
local MENU=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.texi \
|
|
|
4c79b5 |
| egrep -v '^[[:space:]]*$' | egrep -v '^@(end )?menu')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case $ACTION in
|
|
|
4c79b5 |
'remove-entry' )
|
|
|
4c79b5 |
# Remove menu line from chapter's menu.
|
|
|
4c79b5 |
MENU=$(echo "$MENU" | egrep -v "$MENULINE")
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'update-entry' | * )
|
|
|
4c79b5 |
|
|
|
0211a4 |
# behaivour if no argument is passed to help_updateMenu
|
|
|
4c79b5 |
|
|
|
4c79b5 |
MENU="$MENU
|
|
|
4c79b5 |
$MENULINE"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
esac
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Organize menu alphabetically, remove empty and duplicated lines.
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
MENU=$(echo "$MENU" | egrep -v '^[[:space:]]*$' | sort | uniq )
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Rebuild chapter's menu structure adding '@menu' and '@end menu'
|
|
|
4c79b5 |
# lines back in menu.
|
|
|
4c79b5 |
MENU="@menu
|
|
|
4c79b5 |
$MENU
|
|
|
4c79b5 |
@end menu"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
MENU=$(echo "$MENU" | sed -r 's!^[[:space:]]+!!g')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
7f7f8f |
echo "$MENU" > $MANUAL_CHAPTER_DIR/chapter-menu.texi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|