Debian Codegraph @

samples/inputmenu3

raw symbols SCIP
1 #! /bin/sh
2 # $Id: inputmenu3,v 1.14 2020/11/26 00:28:52 tom Exp $
3 #
4 # "inputmenu1" with defaultitem, help-button and item-help.
5
6 . ./setup-vars
7
8 backtitle="An Example for the use of --inputmenu:"
9
10 ids=`id|sed -e 's/([^)]*)//g'`
11 uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
12 gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`
13
14 user="$USER"
15 home="$HOME"
16
17 returncode=0
18 defaultitem="Username:"
19 while test $returncode != 1 && test $returncode != 250
20 do
21 exec 3>&1
22 returntext=`$DIALOG --clear --ok-label "Create" \
23 --backtitle "$backtitle" \
24 --help-button \
25 --help-label "Script" \
26 --default-item "$defaultitem" \
27 --item-help "$@" \
28 --inputmenu "Originally I designed --inputmenu for a \
29 configuration purpose. Here is a possible piece of a configuration program." \
30 20 60 10 \
31 "Username:" "$user" "User login-name" \
32 "UID:" "$uid" "User-ID (number)" \
33 "GID:" "$gid" "Group-ID (number)" \
34 "HOME:" "$home" "User's home-directory" \
35 2>&1 1>&3`
36 returncode=$?
37 exec 3>&-
38
39 case $returncode in
40 $DIALOG_CANCEL)
41 "$DIALOG" \
42 --clear \
43 --backtitle "$backtitle" \
44 --yesno "Really quit?" 10 30
45 case $? in
46 $DIALOG_OK)
47 break
48 ;;
49 $DIALOG_CANCEL)
50 returncode=99
51 ;;
52 esac
53 ;;
54 $DIALOG_OK)
55 case $returntext in
56 HELP*)
57 "$DIALOG" \
58 --textbox "$0" 0 0
59 ;;
60 *)
61 "$DIALOG" \
62 --clear \
63 --backtitle "$backtitle" \
64 --msgbox "useradd \n\
65 -d $home \n\
66 -u $uid \n\
67 -g $gid \n\
68 $user" 10 40
69 ;;
70 esac
71 ;;
72 $DIALOG_HELP)
73 "$DIALOG" \
74 --textbox "$0" 0 0
75 ;;
76 $DIALOG_EXTRA)
77 tag=`echo "$returntext" |sed -e 's/^RENAMED //' -e 's/:.*/:/'`
78 item=`echo "$returntext" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'`
79
80 case "$tag" in
81 Username:)
82 user="$item"
83 ;;
84 UID:)
85 uid="$item"
86 ;;
87 GID:)
88 gid="$item"
89 ;;
90 HOME:)
91 home="$item"
92 ;;
93 *)
94 tag=
95 ;;
96 esac
97 test -n "$tag" && defaultitem="$tag"
98 ;;
99
100 *)
101 . ./report-button
102 break
103 ;;
104
105 esac
106 done