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