summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-01-17 09:35:28 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-01-17 09:35:28 (EST)
commitf47b3b16676ec60d37cd6614b53844ebc26aad61 (patch)
treede11e855e252e1ee20020d57c578f16df54bb072
parentd5e46c35ea98e43b6ad380ac7fbc197b7881b220 (diff)
error(): Add variant that doesn't exit
-rw-r--r--src/output.sh31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/output.sh b/src/output.sh
index 62d2095..320a46b 100644
--- a/src/output.sh
+++ b/src/output.sh
@@ -20,17 +20,28 @@
error()
{
- local status=${1}
- local fmt="${2}"
- shift 2
+ case "${1}" in
+ *[!0-9]*)
+ local fmt="${1}"
+ shift 1
- printf '%s: Error: ' "${0##*/}" >&2
- printf "${fmt}\n" "${@}" >&2
-
- # In a subshell, this will have no effect, so the shell's exit status
- # will be 128+SIGINT. Meh.
- exit_status=${status}
- kill -s INT ${$}
+ printf '%s: Error: ' "${0##*/}" >&2
+ printf "${fmt}\n" "${@}" >&2
+ ;;
+ *)
+ local status=${1}
+ local fmt="${2}"
+ shift 2
+
+ printf '%s: Error: ' "${0##*/}" >&2
+ printf "${fmt}\n" "${@}" >&2
+
+ # In a subshell, this will have no effect, so the
+ # shell's exit status will be 128+SIGINT. Meh.
+ exit_status=${status}
+ kill -s INT ${$}
+ ;;
+ esac
}
warn()