#! /bin/sh #---------------------------------------------------------------------------- # show-menu - show menu # # Copyright (c) 2001-2003 Frank Meyer # # Creation: 04.11.2001 fm # Last Update: 19.07.2003 fm # # 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. #---------------------------------------------------------------------------- menu_file="$1" n=0 while read line do if [ $n = 0 ] then title="$line" else set -- $line command="$1" shift comment="$*" eval comment_$n='"$comment"' eval command_$n='"$command"' fi n=`expr $n + 1` done < $menu_file n=`expr $n - 1` while [ 1 ] do clrhome colecho "$title" gn echo if [ $n -ge 10 ] then lines_used=`expr $n + 1` else lines_used=`expr $n '*' 2 + 2` fi blank_lines=`expr 22 - $lines_used` blank_lines=`expr $blank_lines / 2` i=1 while [ $i -le $blank_lines ] do echo i=`expr $i + 1` done i=1 while [ $i -le $n ] do eval command='$command_'$i eval comment='$comment_'$i if [ $i -lt 10 ] then echo " $i: $comment" else echo " $i: $comment" fi if [ $n -lt 10 ] then echo fi shift i=`expr $i + 1` done echo " 0: Exit" i=1 while [ $i -le $blank_lines ] do echo i=`expr $i + 1` done echo -e "Command (1-$n, ENTER=Return 0=Exit) \c" read a if [ "$a" = 0 ] then exit 127 fi if [ "$a" = "" ] then break fi if [ "$a" != "" -a $a -ge 1 -a $a -le $n ] then eval command='$command_'$a sh $command case $? in 127) exit 127;; 0) ;; *) /var/install/bin/anykey;; esac fi done exit 0