[pacman-dev] [PATCHv3 5/7] pacsearch: skip any non-matching line instead of printing them

Pierre Neidhardt ambrevar at gmail.com
Sun Feb 9 13:41:43 EST 2014


If input cannot be parsed, it is not desirable to output it along other valid
entries. This would make pacsearch output unpredictable.

Signed-off-by: Pierre Neidhardt <ambrevar at gmail.com>
---
 contrib/pacsearch.in | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in
index 0ab840e..df0d62d 100644
--- a/contrib/pacsearch.in
+++ b/contrib/pacsearch.in
@@ -111,11 +111,8 @@ foreach $_ (@syncpkgs) {
 	# desc. We grab leading space for 'group' and 'installed' so that we do not
 	# need to test if non-empty when printing.
 	my @pkgfields = /^(.*?)\/(.*?) (.*?)( \(.*?\))?( \[.*\])?\n(.*)$/s;
-	if(not @pkgfields) {
-		# skip any non-matching line and just print it for the user
-		print $_, "\n";
-		next;
-	}
+	# skip any non-matching line
+	next if not defined $pkgfields[1];
 	# since 'group' and 'installed' are optional, we should fill it in if necessary
 	$pkgfields[3] = "" if not defined $pkgfields[3];
 	$pkgfields[4] = "" if not defined $pkgfields[4];
-- 
1.8.5.4



More information about the pacman-dev mailing list