xref: /freebsd/contrib/dialog/samples/passwordform1 (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1#! /bin/sh
2# $Id: passwordform1,v 1.5 2010/01/13 10:47:35 tom Exp $
3
4. ./setup-vars
5
6backtitle="An Example for the use of --form:"
7
8ids=`id|sed -e 's/([^)]*)//g'`
9uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
10gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`
11
12user="$USER"
13home="$HOME"
14
15returncode=0
16while test $returncode != 1 && test $returncode != 250
17do
18exec 3>&1
19value=`$DIALOG --ok-label "Submit" \
20	  --backtitle "$backtitle" \
21	  --insecure "$@" \
22	  --passwordform "Here is a possible piece of a configuration program." \
2320 50 0 \
24	"Username:" 1 1	"$user" 1 10 10 0 \
25	"UID:"      2 1	"$uid"  2 10  8 0 \
26	"GID:"      3 1	"$gid"  3 10  8 0 \
27	"HOME:"     4 1	"$home" 4 10 40 0 \
282>&1 1>&3`
29returncode=$?
30exec 3>&-
31
32show=`echo "$value" |sed -e 's/^/	/'`
33
34	case $returncode in
35	$DIALOG_CANCEL)
36		"$DIALOG" \
37		--clear \
38		--backtitle "$backtitle" \
39		--yesno "Really quit?" 10 30
40		case $? in
41		$DIALOG_OK)
42			break
43			;;
44		$DIALOG_CANCEL)
45			returncode=99
46			;;
47		esac
48		;;
49	$DIALOG_OK)
50		"$DIALOG" \
51		--clear \
52		--backtitle "$backtitle" --no-collapse --cr-wrap \
53		--msgbox "Resulting data:\n\
54$show" 10 40
55		;;
56	$DIALOG_HELP)
57		echo "Button 2 (Help) pressed."
58		exit
59		;;
60	$DIALOG_EXTRA)
61		echo "Button 3 (Extra) pressed."
62		exit
63		;;
64	*)
65		echo "Return code was $returncode"
66		exit
67		;;
68	esac
69done
70