commit:     6cfcd9b33e08157146d08783872635a0545f4ead
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 14 16:02:20 2014 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Mar 14 16:10:34 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=6cfcd9b3

Don't output spurious whitespace in write_kv_list_entry.

* libs/output.bash.in (write_kv_list_entry): Don't output spurious
trailing whitespace if value is an empty string.

---
 ChangeLog           | 5 +++++
 libs/output.bash.in | 8 +++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 6aad604..0566eeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-14  Ulrich Müller  <[email protected]>
+
+       * libs/output.bash.in (write_kv_list_entry): Don't output spurious
+       trailing whitespace if value is an empty string.
+
 2014-02-25  Ulrich Müller  <[email protected]>
 
        * modules/news.eselect (accepted_languages): Suppress "C"

diff --git a/libs/output.bash.in b/libs/output.bash.in
index 140de9e..2681c8c 100644
--- a/libs/output.bash.in
+++ b/libs/output.bash.in
@@ -110,6 +110,13 @@ write_kv_list_entry() {
        text=${key//\%%%??%%%/}
        n=$(( 26 + ${#rindent} - ${#lindent} - ${#text} ))
 
+       text=${val//\%%%??%%%/}
+       if [[ -z ${text} ]]; then
+               # empty ${val}: end the line and be done
+               echo
+               return
+       fi
+
        # if ${n} is less than or equal to zero then we have a long ${key}
        # that will mess up the formatting of ${val}, so end the line, indent
        # and let ${val} go on the next line. Don't start a new line when
@@ -126,7 +133,6 @@ write_kv_list_entry() {
        echo -n -e "$(space ${n})${right}"
        n=$(( 28 + ${#rindent} ))
 
-       text=${val//\%%%??%%%/}
        # only loop if it doesn't fit on the same line
        if [[ $(( ${n} + ${#text} )) -ge ${cols} ]] && ! is_output_mode brief; 
then
                local i=0 spc=""

Reply via email to