From 16c7f5d2571fcd4b698942990c7e0fd36744a9a0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 24 May 2015 19:19:30 -0600 Subject: libremessages:flag: Clean up math Because I was using -le instead of -lt, all of the math was off by one, which was negated by only one space in the separator in the format string. --- src/lib/libremessages | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/libremessages b/src/lib/libremessages index e7dd885..943aca3 100755 --- a/src/lib/libremessages +++ b/src/lib/libremessages @@ -113,21 +113,21 @@ flag() { # this should be increased in increments of 8 (that is, a # literal-tab). Everything should be wrapped to 75 columns. - # The printf-format we use has 3 spaces built into it (two at - # the beginning, and a seperator). Therefore, the default - # indent is 16-3=13 columns. And the width left for $desc - # is (75-3)-indent = 72-indent. - - declare -i indent=13 - while [[ $indent -le ${#flag} ]]; do - indent=$((indent+8)) + # The printf-format we use has 4 spaces built into it (two at + # the beginning, and two for a seperator). Therefore, the + # default indent is 16-4=12 columns. And the width left for + # $desc is (75-4)-indent = 71-indent. + + declare -i indent=12 + while [[ $indent -lt $flaglen ]]; do + indent+=8 done local fmt2 fmt1 - fmt2=" %-${indent}s %s\n" - printf -v fmt1 " %-${indent}s %%s\n" '' + fmt2=" %-${indent}s %s\n" + printf -v fmt1 " %-${indent}s %%s\n" '' local lines - IFS=$'\n' lines=($(fmt -u -w $((72-indent)) <<<"$desc")) + IFS=$'\n' lines=($(fmt -u -w $((71-indent)) <<<"$desc")) printf -- "$fmt2" "$flag" "${lines[0]}" [[ ${#lines[@]} -lt 2 ]] || printf -- "$fmt1" "${lines[@]:1}" } -- cgit v1.2.2