summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-05-24 19:48:09 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-05-24 19:48:09 -0600
commitb4bed3c0b8e4c5b0c0c2c3b7ff245db1fcc03173 (patch)
tree95fc811c25133be2579b62fc687c635e780bac2e /src/lib
parent384900fcfabcb2ec2a24390494fa0de937b3744f (diff)
libremessages:flag: Avoid doing a loop over each line
Diffstat (limited to 'src/lib')
-rwxr-xr-xsrc/lib/libremessages10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libremessages b/src/lib/libremessages
index 78f9107..e7dd885 100755
--- a/src/lib/libremessages
+++ b/src/lib/libremessages
@@ -122,14 +122,14 @@ flag() {
while [[ $indent -le ${#flag} ]]; do
indent=$((indent+8))
done
+ local fmt2 fmt1
+ fmt2=" %-${indent}s %s\n"
+ printf -v fmt1 " %-${indent}s %%s\n" ''
local lines
IFS=$'\n' lines=($(fmt -u -w $((72-indent)) <<<"$desc"))
- local line
- for line in "${lines[@]}"; do
- printf " %-${indent}s %s\n" "$flag" "$line"
- flag=''
- done
+ printf -- "$fmt2" "$flag" "${lines[0]}"
+ [[ ${#lines[@]} -lt 2 ]] || printf -- "$fmt1" "${lines[@]:1}"
}
# Usage: term_title MESG [ARGS...]