[Gllug] Ckyorn and friends

Richard Cohen richard at vmlinuz.org
Tue Jan 22 12:28:24 UTC 2002


On Tue, 22 Jan 2002, Flash Wilson wrote:

> Hello.
>
> Is there an equivalent of ckyorn and/or a command to
> do menu options ("do you want 1, 2 or 3, default is 1")
> for linux?
>
> I can of course rewrite them within my script, but I'd rather
> use the correct function if it exists.

Check the select command in the bash manpage.

Alternatively, write your own like this:

return=0
while [ $return -lt 1 -o $return -gt 3 ]
do
	echo "1) Option 1 (default)"
	echo "2) Option 2"
	echo "3) Option 3"
	echo
	read -e -p "Please select an option (1,2,3): " return
# or use the following for purer sh, as opposed to bash
#	echo "Please select an option (1,2,3): \c"
#	read return

	case "$return" in
		"" )
			return=1 ;;
		"1" | "2" | "3" )
			;;
		*)
			return=0 ;;
	esac
done

> Im using plain old sh on Redhat 7.1.
>
> Thanks,

Cheers
Richard


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list