All pastes #626444 Raw Edit

Something

public text v1 · immutable
·published 2007-07-19 17:43 UTC
rendered paste body
#!/bin/bash

#mcookie random

clear
prompt=">"
hal_say="HAL: "
sep="-----------------------------"

echo
echo "  ***** HAL 1.0 *****"
echo
echo $hal_say"Type 'list' to get all commands."

upper(){
	if [ -z "$1" ]
	then
		echo 0
		return
	fi

	strin=`echo $1 | tr a-z A-Z`	
	echo $strin
	return
}

command(){
	ret=`grep -cw ^$1 command_list`
	if [ $ret == 0 ]
	then echo $hal_say"$1: command not found. Type 'list' to get all commands."
	else
		no_opt="$1: option needed. Type '$1 list' to get all options."
		if [ $1 == list ]
		then
			echo $sep
			sort command_list
			echo $sep
		fi

		if [ $1 == stop ]
		then exit
		fi

		if [ $1 == map ]
		then
			if [ $2 ]
			then
				if [ $2 == list ]
				then cat -n map_list.cfg
				fi
			else echo $hal_say$no_opt
			fi
		fi
	fi
return
}


while true
do
	echo -n $prompt
	read line

	if [ "$line" != "" ]
	then command $line
	fi

done