diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-05-24 19:19:30 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-05-24 19:48:13 -0600 |
commit | 16c7f5d2571fcd4b698942990c7e0fd36744a9a0 (patch) | |
tree | 8a2f1b898a5e20e51c10546f64efc3267630a139 /src | |
parent | b4bed3c0b8e4c5b0c0c2c3b7ff245db1fcc03173 (diff) |
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.
Diffstat (limited to 'src')
-rwxr-xr-x | src/lib/libremessages | 22 |
1 files 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}" } |