summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-24 15:20:10 -0600
committerDan McGee <dan@archlinux.org>2011-01-24 15:20:10 -0600
commit0f24390fe8967f25d7fce4665d5b635fa66a3c4f (patch)
treedffb60c277eb886cf9b374c3630c110855ac41b0
parentd6a997ee383a8228a0f5bf18af56febb7b6bc189 (diff)
downloadpacman-0f24390fe8967f25d7fce4665d5b635fa66a3c4f.tar.xz
pkgsearch: handle non-matching lines gracefully
Before any non-matching line would trigger some perl warnings about undefined variables. If a line doesn't match, just show it to the user unprocessed; this is seen with warning and error messages pacman not so helpfully emits on stdout rather than stderr. Signed-off-by: Dan McGee <dan@archlinux.org>
-rwxr-xr-xcontrib/pacsearch.in12
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in
index a20df265..dd848a73 100755
--- a/contrib/pacsearch.in
+++ b/contrib/pacsearch.in
@@ -1,10 +1,10 @@
#!/usr/bin/perl
# pacsearch - Adds color and install information to a 'pacman -Ss' search
#
-# Copyright (C) 2008, 2010 Dan McGee <dpmcgee@gmail.com>
+# Copyright (C) 2008-2011 Dan McGee <dan@archlinux.org>
#
# Based off original shell script version:
-# Copyright (C) 2006-2007 Dan McGee <dpmcgee@gmail.com>
+# Copyright (C) 2006-2007 Dan McGee <dan@archlinux.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -39,7 +39,7 @@ if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") {
print "$progname version $version\n";
- print "Copyright (C) 2006-2010 Dan McGee\n";
+ print "Copyright (C) 2006-2011 Dan McGee\n";
exit 0;
}
@@ -65,6 +65,7 @@ sub to_color {
$line =~ s/(^community\/.*)/$CLR3$1$BASE/;
$line =~ s/(^testing\/.*)/$CLR4$1$BASE/;
$line =~ s/(^community-testing\/.*)/$CLR5$1$BASE/;
+ $line =~ s/(^multilib\/.*)/$CLR6$1$BASE/;
$line =~ s/(^local\/.*)/$CLR7$1$BASE/;
# any other unknown repository
$line =~ s/(^[\w-]*\/.*)/$CLR6$1$BASE/;
@@ -86,6 +87,11 @@ my $cnt = 0;
foreach $_ (@syncpkgs) {
# we grab 4 fields here: repo, name/ver, installed, and desc
my @pkgfields = /^(.*?)\/(.*?) ?(\[.*\])?\n(.*)$/s;
+ if(not @pkgfields) {
+ # skip any non-matching line and just print it for the user
+ print $_, "\n";
+ next;
+ }
# since installed is optional, we should fill it in if necessary
$pkgfields[2] = "" if not defined $pkgfields[2];
# add a fifth field that indicates original order