summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-04-20 22:45:50 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-01 17:24:16 -0400
commitcd795c1446b705b2e14cf70655e859571d4f8755 (patch)
treee33de6e6fa8a141853996fe7ef6e7b3d45aae666 /src
parent3a18b5e8cf50b688f3c6e0ffbaaa1c70cf09f484 (diff)
Clean up argument parsing for libremessages formatters.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chroot-tools/distcc-tool11
-rwxr-xr-xsrc/lib/librelib5
-rw-r--r--src/lib/messages.sh11
3 files changed, 12 insertions, 15 deletions
diff --git a/src/chroot-tools/distcc-tool b/src/chroot-tools/distcc-tool
index d181109..ba0c9bc 100755
--- a/src/chroot-tools/distcc-tool
+++ b/src/chroot-tools/distcc-tool
@@ -37,20 +37,19 @@ fi
q0="$(printf '%q' "$0")" # quoted $0
panic() {
- echo "$(gettext 'panic: malformed call to internal function')" >&2
+ gettext 'panic: malformed call to internal function' >&2
exit 1
}
error() {
- mesg="$(gettext "$1")"; shift
- printf "$(gettext 'ERROR:') $mesg\n" "$@" >&2
+ local mesg; mesg="$(gettext "$1")"; shift
+ printf -- "$(gettext 'ERROR:') $mesg\n" "$@" >&2
exit 1
}
print() {
- local mesg=$1
- shift
- printf -- "$(gettext "$mesg")\n" "$@"
+ local mesg; mesg="$(gettext "$1")"; shift
+ printf -- "$mesg\n" "$@"
}
usage() {
diff --git a/src/lib/librelib b/src/lib/librelib
index fc03e32..5f17b6f 100755
--- a/src/lib/librelib
+++ b/src/lib/librelib
@@ -29,8 +29,7 @@ _l() {
}
print() {
- local mesg="$(_ "$1")"
- shift
+ local mesg; mesg="$(_ "$1")"; shift
printf -- "$mesg\n" "$@"
}
@@ -41,7 +40,7 @@ whitespace_collapse() {
}
prose() {
- local mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift
+ local mesg; mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift
printf -- "$mesg" "$@" | fmt -u
}
diff --git a/src/lib/messages.sh b/src/lib/messages.sh
index e85590f..2dc53d6 100644
--- a/src/lib/messages.sh
+++ b/src/lib/messages.sh
@@ -43,7 +43,7 @@
#
# For programming errors, bails immediately with little fanfare.
panic() {
- echo "$(_l _ 'panic: malformed call to internal function')" >&2
+ _l _ 'panic: malformed call to internal function' >&2
exit 1
}
@@ -52,8 +52,7 @@ panic() {
# Like printf, but gettext-aware, and prints a trailing newline
print() {
[[ $# -ge 1 ]] || panic
- local mesg="$(_ "$1")"
- shift
+ local mesg; mesg="$(_ "$1")"; shift
printf -- "$mesg\n" "$@"
}
@@ -78,7 +77,7 @@ whitespace_collapse() {
# printing a paragraph of prose in --help text.
prose() {
[[ $# -ge 1 ]] || panic
- local mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift
+ local mesg; mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift
printf -- "$mesg" "$@" | fmt -u
}
@@ -87,7 +86,7 @@ prose() {
# remaining lines.
bullet() {
[[ $# -ge 1 ]] || panic
- local mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift
+ local mesg; mesg="$(_ "$(whitespace_collapse <<<"$1")")"; shift
# Wrap the text to 71 columns; 75 (the default) minus a 4 column indent
printf -- "$mesg" "$@" | fmt -u -w 71 | sed -e '1s/^/ - /' -e '2,$s/^/ /'
}
@@ -152,7 +151,7 @@ flag() {
else
[[ $# -gt 1 ]] || panic
local flag=$1
- local desc="$(_ "$(whitespace_collapse <<<"$2")")"
+ local desc; desc="$(_ "$(whitespace_collapse <<<"$2")")"
shift 2
local lines