From 888eaffd36ff841a0b7c562de67e498336270ce7 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Fri, 26 Dec 2014 16:19:46 +1100 Subject: import --- feedback_defs.sh | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 feedback_defs.sh (limited to 'feedback_defs.sh') diff --git a/feedback_defs.sh b/feedback_defs.sh new file mode 100755 index 0000000..791308b --- /dev/null +++ b/feedback_defs.sh @@ -0,0 +1,93 @@ +# +# quit -- Display a message and terminate abnormally. +# +# Calling Sintax: +# quit [ ... ] +# +# Where: +# Feedback message. It can contain printf() conversion +# specifications. +# +# Argument operand printed under the control of the +# 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 [ ... ] +# +# Where: +# Feedback message. It can contain printf() conversion +# specifications. +# +# Argument operand printed under the control of the +# 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 [ ... ] +# +# Where: +# Name of the environment variable which is going to +# receive the user introduced value. +# +# Prompt to display to the user. It can contain printf() +# conversion specifications. +# +# Argument operand printed under the control of the +# operand. +# +# Remarks: +# The 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" +} -- cgit v1.2.3