#!/bin/sh
#

# I prefer to tell "samples/yesno" for the source directory
D=/usr/bin/dialog

tmp=/tmp/menu.tmp.$$
$D --clear --title "MENU BOX" \
        --menu "This menubox features the old \
semantics. This kind of invocation is compatble with any shell script \
using dialog which resides on your disk. Choose the OS you like:" 14 51 4 \
        "Linux"  "The Great Unix Clone for 386/486" \
        "NetBSD" "Another free Unix Clone for 386/486" \
        "OS/2" "IBM OS/2" \
        "WIN NT" "Microsoft Windows NT" \
        "PCDOS"  "IBM PC DOS" \
        "MSDOS"  "Microsoft DOS" 2> $tmp

retval=$?

choice=`cat $tmp`
rm -f $tmp

case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
esac


# This invocation uses stdout as output channel. Only works with 0.67
# and later dialogs. The size is automatic (maximum), and "-x 5" is
# the list height.

choice=`$D -o " Agree :aBandon" -T Licensing -m "In order to run this \
software, you must agree to one of the following licences." \
         GPL          "The Gnu Public Licence" \
	 LGPL         "The Library-GPL" \
	 MIT          "Like X11" \
	 berkeley     "Another approach to freeware" \
	"binary Only" "Hmmm..."`

echo "you chose $choice"


# This one uses both stdin and stdout. Input comes from stdin.

dir=.
while [ -d $dir ]
do
  # This strips extra slashes, and '..' fields
  dir=`cd $dir; pwd`

  choice=`ls -a1F $dir | $D -1 -T Files \
           -m "Choose one of the following files"`
  retval=$?
  if [ $retval -ne 0 ] ; then break; fi
  dir="$dir/$choice"
done

if [ $retval -eq 0 ]; then echo "you chose $dir"; fi
