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