[kwlug-disc] my new favourite command

Chris Frey cdfrey at foursquare.net
Thu Dec 2 16:50:08 EST 2010


On Thu, Dec 02, 2010 at 03:49:20PM -0500, John Van Ostrand wrote:
> This is a side question. Is there another way to put readline functionality in a bash shell script?
> 
> e.g.
> 
> while :
> do
>     read cmd
> 
>     case "$cmd" in
>     "load")
>          ...
>     "save")
>          ...
>     esac
> done

If the entire script is supposed to be interactive, the easiest way is
probably to put rlwrap in the shebang:

	#!/usr/bin/rlwrap /bin/bash

	while true ; do
		read cmd
		echo "You typed: $cmd"
	done

- Chris





More information about the kwlug-disc mailing list