From 5032fd43cfa0585e8b3f0fca94a7bc50832fc5bc Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 12 Mar 2019 00:52:06 -0400 Subject: ob_error(), ob_warn(), ob_info(): Rewrite --- (limited to 'lib') 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 } -- cgit v0.9.1