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