public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/eselect:nolinewrap commit in: libs/, /
Date: Thu, 14 Nov 2013 23:56:38 +0000 (UTC)	[thread overview]
Message-ID: <1384473451.0cc6b9ec3d967d87591d3c25c467bd8aa16bdf96.ulm@gentoo> (raw)

commit:     0cc6b9ec3d967d87591d3c25c467bd8aa16bdf96
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 14 22:56:29 2013 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Nov 14 23:57:31 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=0cc6b9ec

Suppress wrapping of lines in brief output mode, bug 490882.

* libs/output.bash.in (write_kv_list_entry): Suppress wrapping
of lines in brief output mode, in order to make automatic parsing
easier. Bug 490882.

---
 ChangeLog           |  4 ++++
 libs/output.bash.in | 13 +++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e6a6731..e3e4e85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-11-14  Ulrich Müller  <ulm@gentoo.org>
 
+	* libs/output.bash.in (write_kv_list_entry): Suppress wrapping
+	of lines in brief output mode, in order to make automatic parsing
+	easier. Bug 490882.
+
 	* modules/modules.eselect (do_list): New local option --only-names
 	will output names of modules only, without their description.
 	This replaces the previous brief output mode behaviour and is

diff --git a/libs/output.bash.in b/libs/output.bash.in
index 5390792..92c367b 100644
--- a/libs/output.bash.in
+++ b/libs/output.bash.in
@@ -112,10 +112,15 @@ write_kv_list_entry() {
 
 	# 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.
+	# and let ${val} go on the next line. Don't start a new line when
+	# in brief output mode, in order to keep the output easily parsable.
 	if [[ ${n} -le 0 ]]; then
-		echo
-		n=$(( 28 + ${#rindent} ))
+		if is_output_mode brief; then
+			n=1
+		else
+			echo
+			n=$(( 28 + ${#rindent} ))
+		fi
 	fi
 
 	echo -n -e "$(space ${n})${right}"
@@ -123,7 +128,7 @@ write_kv_list_entry() {
 
 	text=${val//\%%%??%%%/}
 	# only loop if it doesn't fit on the same line
-	if [[ $(( ${n} + ${#text} )) -ge ${cols} ]]; then
+	if [[ $(( ${n} + ${#text} )) -ge ${cols} ]] && ! is_output_mode brief; then
 		local i=0 spc=""
 		rindent=$(space ${n})
 		local cwords=( $(apply_text_highlights "${right}" "${val}") )


                 reply	other threads:[~2013-11-14 23:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384473451.0cc6b9ec3d967d87591d3c25c467bd8aa16bdf96.ulm@gentoo \
    --to=ulm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox