aboutsummaryrefslogtreecommitdiff
path: root/feedback_defs.sh
blob: 791308bc104a0dfdde469f5857b012584e92beab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#
# quit -- Display a message and terminate abnormally.
#
# Calling Sintax:
#	quit <pformat> [ <parg> ... ]
#
# Where:
#	<pformat>	Feedback message. It can contain printf() conversion
#			specifications.
#
#	<parg>		Argument operand printed under the control of the
#			<pformat> operand.
quit ()
{
	quitparms=
	if [ $# -gt 1 ]; then
		quitparm=2
		while test $quitparm -le $#; do
			quitparms="$quitparms \"\$$quitparm\""
			quitparm=`expr $quitparm + 1`
		done
	fi
	eval "printf \"$1\n\" $quitparms"
	exit 1
}



#
# fbck -- Display a feedback message.
#
# Calling Sintax:
#	fbck <pformat> [ <parg> ... ]
#
# Where:
#	<pformat>	Feedback message. It can contain printf() conversion
#			specifications.
#
#	<parg>		Argument operand printed under the control of the
#			<pformat> operand.
#
# Remarks:
#	The message is displayed only if the environment variable 'verbose' has
# the 'yes' value.
#
fbck ()
{
	fbckparms=
	if [ $# -gt 1 ]; then
		fbckparm=2
		while test $fbckparm -le $#; do
			fbckparms="$fbckparms \"\$$fbckparm\""
			fbckparm=`expr $fbckparm + 1`
		done
	fi
	test "$verbose" = "yes" && eval "printf \"$1\n\" $fbckparms"
}



#
# prompt - Ask the user for the value to assign to an environment variable.
#
# Calling Sintax:
#	prompt <varnam> <pformat> [ <parg> ... ]
#
# Where:
#	<varnam>	Name of the environment variable which is going to
#			receive the user introduced value.
#
#	<pformat>	Prompt to display to the user. It can contain printf()
#			conversion specifications.
#
#	<parg>		Argument operand printed under the control of the
#			<pformat> operand.
#
# Remarks:
#	The <varname> variable is not exported.
#
prompt ()
{
	promptparms=
	if [ $# -gt 2 ]; then
		promptparm=3
		while test $promptparm -le $#; do
			promptparms="$promptparms \"\$$promptparm\""
			promptparm=`expr $promptparm + 1`
		done
	fi
	eval "printf \"$2\" $promptparms"
	read promptresponse
	eval $1="$promptresponse"
}