summaryrefslogtreecommitdiffstats
path: root/lib/output.sh
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-12 00:52:06 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-12 00:52:06 (EDT)
commit5032fd43cfa0585e8b3f0fca94a7bc50832fc5bc (patch)
tree23a147792e53fcc218d8c2c3cc01adf9eba5aea6 /lib/output.sh
parent96851fd522ae3540314ac5c5d4d4fbec1448ca4b (diff)
ob_error(), ob_warn(), ob_info(): Rewrite
Diffstat (limited to 'lib/output.sh')
-rw-r--r--lib/output.sh29
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/output.sh b/lib/output.sh
index bc262e9..bd56715 100644
--- a/lib/output.sh
+++ b/lib/output.sh
@@ -31,9 +31,10 @@
## @pure no This function causes the current shell to exit.
ob_error()
{
- printf '%s: Error: ' "${0##*/}" >&2
- printf "${@}" >&2
- printf '\n' >&2
+ local format="${1}"
+ shift 1
+
+ printf '%s: Error: %s\n' "${0##*/}" "${@}" >&2
exit 1
}
@@ -44,19 +45,16 @@ ob_error()
## of \fIformat\fP.
## @operand arguments opt Arguments to be printed, as referenced by
## \fIformat\fP.
-## @return Returns 0 on success or 125 if \fIformat\fP is missing.
+## @return Returns 0.
## @stderr This function prints the formatted message, preceded by the program
## name and "Warning:", to stderr.
## @pure yes This function has no side effects.
ob_warn()
{
- if [ ${#} -eq 0 ]; then
- return 125
- fi
+ local format="${1}"
+ shift 1
- printf '%s: Warning: ' "${0##*/}" >&2
- printf "${@}" >&2
- printf '\n' >&2
+ printf '%s: Warning: %s\n' "${0##*/}" "${@}" >&2
return 0
}
@@ -67,19 +65,16 @@ ob_warn()
## of \fIformat\fP.
## @operand arguments opt Arguments to be printed, as referenced by
## \fIformat\fP.
-## @return Returns 0 on success or 125 if \fIformat\fP is missing.
+## @return Returns 0.
## @stderr This function prints the formatted message, preceded by the program
## name, to stderr.
## @pure yes This function has no side effects.
ob_info()
{
- if [ ${#} -eq 0 ]; then
- return 125
- fi
+ local format="${1}"
+ shift 1
- printf '%s: ' "${0##*/}" >&2
- printf "${@}" >&2
- printf '\n' >&2
+ printf '%s: %s\n' "${0##*/}" "${@}" >&2
return 0
}