diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-04-20 22:45:50 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-05-01 17:24:16 -0400 |
commit | cd795c1446b705b2e14cf70655e859571d4f8755 (patch) | |
tree | e33de6e6fa8a141853996fe7ef6e7b3d45aae666 /src/lib/messages.sh | |
parent | 3a18b5e8cf50b688f3c6e0ffbaaa1c70cf09f484 (diff) |
Clean up argument parsing for libremessages formatters.
Diffstat (limited to 'src/lib/messages.sh')
-rw-r--r-- | src/lib/messages.sh | 11 |
1 files changed, 5 insertions, 6 deletions
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 |