inputmenu revision 3d4e8889889e5e36302454225999f7e146d3219c
1#! /bin/bash
2# $Id: inputmenu,v 1.10 2010/01/13 10:29:22 tom Exp $
3# 2002 - written by Tobias Rittweiler <tobrit@freebits.de>
4
5. ./setup-vars
6
7user="$USER"    ; uid="$UID"   ;
8gid="$GROUPS"  ; home="$HOME"  ;
9
10while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
11       exec 3>&1
12       value=$("$DIALOG" --clear --ok-label "Create" \
13                          --backtitle "An Example for the use of --inputmenu:" "$@" \
14                          --inputmenu "Originally I designed --inputmenu for a \
15configuration purpose. Here is a possible piece of a configuration program. \
16" 20 50 10 \
17"Username:" "$user" \
18"UID:"      "$uid" \
19"GID:"      "$gid" \
20"HOME:"     "$home" \
212>&1 1>&3 )
22       returncode=$?
23       exec 3>&-
24       case $returncode in
25       $DIALOG_CANCEL)
26               "$DIALOG"  --clear --backtitle "An Example for the use of --inputmenu:" \
27                               --yesno "Really quit?" 10 30
28               case $? in
29                       $DIALOG_OK) break;;
30                       $DIALOG_CANCEL) returncode=99;;
31               esac
32               ;;
33       $DIALOG_OK)
34               "$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:"  \
35			--msgbox "useradd \n\
36				-d $home \n\
37				-u $uid \n\
38				-g $gid \n\
39				$user" 10 40
40               ;;
41       $DIALOG_EXTRA)
42               value="${value:8:${#value}}"
43               tag="${value%:*}"
44               item="${value#*: }"
45
46               case "$tag" in
47                       Username) user="$item";;
48                       UID) uid="$item";;
49                       GID) gid="$item";;
50                       HOME) home="$item";;
51               esac
52               ;;
53
54       $DIALOG_ESC)
55                echo "ESC pressed."
56                break
57                ;;
58
59       esac
60done
61