#!/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/sort-menu - sort menu file on EIS/FAIR # # Copyright (c) 2001-2005 The Eisfair Team, c/o Frank Meyer, frank(at)eisfair(dot)org # # Creation: 2005-11-25 jed # Last Update: $Id$ # # Usage: sort-menu menu-file-name # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------------- # include eislib . /var/install/include/eislib #---------------------------------------------------------------------------------- # extract menu information #---------------------------------------------------------------------------------- extract_menu_entries () { # menu entry echo "$line" | grep -q "^<" if [ $? -eq 0 ] then # new format echo "$line:$idx" | cut -d'>' -f2- else # old format echo "$line:$idx" | cut -d' ' -f2- fi } #---------------------------------------------------------------------------------- # write sorted menu to temporary file #---------------------------------------------------------------------------------- write_sorted_menu () { # write sorted menu idx=1 while read line do _oldifs=$IFS IFS=":" set $line IFS=$_oldifs sed -n ${2}p $menu_file | sed 's/^[ \t]*//' >> ${tmp_file}.2 done < ${tmp_file}.1 } #================================================================================== # main #================================================================================== if [ $# -eq 0 ] then # help mecho -warn "Insufficent parameters" mecho mecho "Usage: sort-menu menu-file-name" exit 1 else menu_file=$1 echo $menu_file | grep -q "/" if [ $? -ne 0 ] then # add menu path menu_file="/var/install/menu/$menu_file" fi fi if [ ! -f $menu_file ] then mecho -error "Menu file '$menu_file' cannot be found!" exit 1 fi tmp_file=/tmp/sort_menu rm -f ${tmp_file}.1 ${tmp_file}.2 if [ "`head -c1 $menu_file`" = "<" ] then ### new menu format ### idx=1 while read line do echo "$line" | grep -E -q "^