Debian Codegraph @

samples/inputmenu2

raw symbols SCIP
1 #! /bin/sh
2 # $Id: inputmenu2,v 1.12 2020/11/26 00:29:26 tom Exp $
3 #
4 # "inputmenu1" with defaultitem, help-button.
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 --inputmenu "Originally I designed --inputmenu for a \
28 configuration purpose. Here is a possible piece of a configuration program." \
29 20 60 10 \
30 "Username:" "$user" \
31 "UID:" "$uid" \
32 "GID:" "$gid" \
33 "HOME:" "$home" \
34 2>&1 1>&3`
35 returncode=$?
36 exec 3>&-
37
38 case $returncode in
39 $DIALOG_HELP)
40 "$DIALOG" \
41 --textbox "$0" 0 0
42 ;;
43 $DIALOG_CANCEL)
44 "$DIALOG" \
45 --clear \
46 --backtitle "$backtitle" \
47 --yesno "Really quit?" 10 30
48 case $? in
49 $DIALOG_OK)
50 break
51 ;;
52 $DIALOG_CANCEL)
53 returncode=99
54 ;;
55 esac
56 ;;
57 $DIALOG_OK)
58 "$DIALOG" \
59 --clear \
60 --backtitle "$backtitle" \
61 --msgbox "useradd \n\
62 -d $home \n\
63 -u $uid \n\
64 -g $gid \n\
65 $user" 10 40
66 ;;
67 $DIALOG_EXTRA)
68 tag=`echo "$returntext" |sed -e 's/^RENAMED //' -e 's/:.*/:/'`
69 item=`echo "$returntext" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'`
70
71 case "$tag" in
72 Username:)
73 user="$item"
74 ;;
75 UID:)
76 uid="$item"
77 ;;
78 GID:)
79 gid="$item"
80 ;;
81 HOME:)
82 home="$item"
83 ;;
84 *)
85 tag=
86 ;;
87 esac
88 test -n "$tag" && defaultitem="$tag"
89 ;;
90
91 *)
92 . ./report-button
93 break
94 ;;
95
96 esac
97 done