From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-642265-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id B6733138247
	for <garchives@archives.gentoo.org>; Tue, 19 Nov 2013 08:17:29 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 9E800E09D7;
	Tue, 19 Nov 2013 08:17:27 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 20115E09D7
	for <gentoo-commits@lists.gentoo.org>; Tue, 19 Nov 2013 08:17:27 +0000 (UTC)
Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 0A33D33F2DD
	for <gentoo-commits@lists.gentoo.org>; Tue, 19 Nov 2013 08:17:26 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id B660EE54BD
	for <gentoo-commits@lists.gentoo.org>; Tue, 19 Nov 2013 08:17:23 +0000 (UTC)
From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" <ulm@gentoo.org>
Message-ID: <1384502491.7e66a8cfbe7c3ca2b56aae3f4de648875d29241f.ulm@gentoo>
Subject: [gentoo-commits] proj/eselect:master commit in: libs/, /
X-VCS-Repository: proj/eselect
X-VCS-Files: ChangeLog libs/output.bash.in
X-VCS-Directories: libs/ /
X-VCS-Committer: ulm
X-VCS-Committer-Name: Ulrich Müller
X-VCS-Revision: 7e66a8cfbe7c3ca2b56aae3f4de648875d29241f
X-VCS-Branch: master
Date: Tue, 19 Nov 2013 08:17:23 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 6074c76b-0911-4b31-a3b5-801a96797e88
X-Archives-Hash: 1d8b53bd5dbbb27bf2ebda443d5e0c74

commit:     7e66a8cfbe7c3ca2b56aae3f4de648875d29241f
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: Fri Nov 15 08:01:31 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=7e66a8cf

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 9390b25..536344e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-11-15  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}") )