]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/dialog/samples/form4
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / dialog / samples / form4
1 #! /bin/sh
2 # $Id: form4,v 1.6 2010/01/13 10:49:52 tom Exp $
3 # form3 with --item-help
4
5 . ./setup-vars
6
7 backtitle="An Example for the use of --form:"
8
9 ids=`id|sed -e 's/([^)]*)//g'`
10 uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
11 gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`
12
13 user="$USER"
14 home="$HOME"
15
16 returncode=0
17 while test $returncode != 1 && test $returncode != 250
18 do
19 exec 3>&1
20 value=`$DIALOG --ok-label "Submit" \
21           --help-button \
22           --item-help \
23           --backtitle "$backtitle" "$@" \
24           --form "Here is a possible piece of a configuration program." \
25 20 50 0 \
26         "Username:" 1 1 "$user" 1 10 10 0 "Login name" \
27         "UID:"      2 1 "$uid"  2 10  8 0 "User ID" \
28         "GID:"      3 1 "$gid"  3 10  8 0 "Group ID" \
29         "HOME:"     4 1 "$home" 4 10 40 0 "User's home-directory" \
30 2>&1 1>&3`
31 returncode=$?
32 exec 3>&-
33
34 show=`echo "$value" |sed -e 's/^/       /'`
35
36         case $returncode in
37         $DIALOG_CANCEL)
38                 "$DIALOG" \
39                 --clear \
40                 --backtitle "$backtitle" \
41                 --yesno "Really quit?" 10 30
42                 case $? in
43                 $DIALOG_OK)
44                         break
45                         ;;
46                 $DIALOG_CANCEL)
47                         returncode=99
48                         ;;
49                 esac
50                 ;;
51         $DIALOG_OK)
52                 "$DIALOG" \
53                 --clear \
54                 --backtitle "$backtitle" --no-collapse --cr-wrap \
55                 --msgbox "Resulting data:\n\
56 $show" 10 40
57                 ;;
58         $DIALOG_HELP)
59                 "$DIALOG" \
60                 --clear \
61                 --backtitle "$backtitle" --no-collapse --cr-wrap \
62                 --msgbox "Help data:\n\
63 $show" 10 40
64                 ;;
65         *)
66                 echo "Return code was $returncode"
67                 exit
68                 ;;
69         esac
70 done