xref: /freebsd/contrib/dialog/samples/inputmenu-stdout (revision d3d381b2b194b4d24853e92eecef55f262688d1a)
1#! /bin/sh
2# $Id: inputmenu-stdout,v 1.13 2012/07/06 18:11:12 tom Exp $
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"
11
12while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
13	value=`$DIALOG \
14		--stdout --clear --ok-label "Create" \
15		--backtitle "An Example for the use of --inputmenu:" "$@" \
16		--inputmenu "Originally I designed --inputmenu for a \
17configuration purpose. Here is a possible piece of a configuration program. \
18" 20 50 10 \
19"Username:" "$user" \
20"UID:"      "$uid" \
21"GID:"      "$gid" \
22"HOME:"     "$home" \
23`
24	returncode=$?
25	case $returncode in
26	$DIALOG_CANCEL)
27		"$DIALOG" \
28			--clear --backtitle "An Example for the use of --inputmenu:" \
29			--yesno "Really quit?" 10 30
30		case $? in
31		$DIALOG_OK) break;;
32		$DIALOG_CANCEL) returncode=99;;
33		esac
34		;;
35	$DIALOG_OK)
36		"$DIALOG" \
37			--clear --backtitle "An Example for the use of --inputmenu:"  \
38			--msgbox "useradd \n\
39				-d $home \n\
40				-u $uid \n\
41				-g $gid \n\
42				$user" 10 40
43		;;
44	$DIALOG_EXTRA)
45		value=`echo "$value" | sed -e 's/^RENAMED //'`
46		tag=`echo "$value" | sed -e 's/:.*//'`
47		item=`echo "$value" | sed -e 's/^[^:]*:[ 	][ 	]*//'`
48
49		case "$tag" in
50		Username) user="$item" ;;
51		UID)	  uid="$item"  ;;
52		GID)	  gid="$item"  ;;
53		HOME)	  home="$item" ;;
54		esac
55		;;
56
57	$DIALOG_ESC)
58		echo "ESC pressed."
59		break
60		;;
61
62	esac
63done
64