]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/dialog/samples/inputmenu-stdout
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / dialog / samples / inputmenu-stdout
1 #! /bin/sh
2 # $Id: inputmenu-stdout,v 1.13 2012/07/06 18:11:12 tom Exp $
3 # 2002 - written by Tobias Rittweiler <tobrit@freebits.de>
4
5 . ./setup-vars
6
7 user="$USER"
8 uid=`id|sed -e 's/^uid=//' -e 's/(.*//'`
9 gid=`id|sed -e 's/^.*gid=//' -e 's/(.*//'`
10 home="$HOME"
11
12 while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
13         value=`$DIALOG \
14                 --stdout --clear --ok-label "Create" \
15                 --backtitle "An Example for the use of --inputmenu:" "$@" \
16                 --inputmenu "Originally I designed --inputmenu for a \
17 configuration purpose. Here is a possible piece of a configuration program. \
18 " 20 50 10 \
19 "Username:" "$user" \
20 "UID:"      "$uid" \
21 "GID:"      "$gid" \
22 "HOME:"     "$home" \
23 `
24         returncode=$?
25         case $returncode in
26         $DIALOG_CANCEL)
27                 "$DIALOG" \
28                         --clear --backtitle "An Example for the use of --inputmenu:" \
29                         --yesno "Really quit?" 10 30
30                 case $? in
31                 $DIALOG_OK) break;;
32                 $DIALOG_CANCEL) returncode=99;;
33                 esac
34                 ;;
35         $DIALOG_OK)
36                 "$DIALOG" \
37                         --clear --backtitle "An Example for the use of --inputmenu:"  \
38                         --msgbox "useradd \n\
39                                 -d $home \n\
40                                 -u $uid \n\
41                                 -g $gid \n\
42                                 $user" 10 40
43                 ;;
44         $DIALOG_EXTRA)
45                 value=`echo "$value" | sed -e 's/^RENAMED //'`
46                 tag=`echo "$value" | sed -e 's/:.*//'`
47                 item=`echo "$value" | sed -e 's/^[^:]*:[        ][      ]*//'`
48
49                 case "$tag" in
50                 Username) user="$item" ;;
51                 UID)      uid="$item"  ;;
52                 GID)      gid="$item"  ;;
53                 HOME)     home="$item" ;;
54                 esac
55                 ;;
56
57         $DIALOG_ESC)
58                 echo "ESC pressed."
59                 break
60                 ;;
61
62         esac
63 done