[pacman-dev] CVS update of pacman-lib (contrib/pacsearch src/pacman/query.c)

Dan McGee dan at archlinux.org
Tue Mar 6 17:06:28 EST 2007


    Date: Tuesday, March 6, 2007 @ 17:06:28
  Author: dan
    Path: /home/cvs-pacman/pacman-lib

Modified: contrib/pacsearch (1.1 -> 1.2) src/pacman/query.c (1.27 -> 1.28)

* -Qs was returning an error if no package found, which is not the same behavior as -Ss.


--------------------+
 contrib/pacsearch  |   20 +++++++++++++++++++-
 src/pacman/query.c |    2 +-
 2 files changed, 20 insertions(+), 2 deletions(-)


Index: pacman-lib/contrib/pacsearch
diff -u pacman-lib/contrib/pacsearch:1.1 pacman-lib/contrib/pacsearch:1.2
--- pacman-lib/contrib/pacsearch:1.1	Fri Feb 16 23:39:59 2007
+++ pacman-lib/contrib/pacsearch	Tue Mar  6 17:06:28 2007
@@ -20,6 +20,7 @@
 #TODO: colors flag on commandline
 
 readonly progname="pacsearch"
+readonly version="1.0"
 
 readonly CLR1='\\\e[0;34m'
 readonly CLR2='\\\e[0;32m'
@@ -31,21 +32,36 @@
 readonly INST='\\\e[1;31m'
 readonly BASE='\\\e[0m'
 
-if [ -z "$1" ]; then
+if [ "$1" = "--help" -o "$1" = "-h" ]; then
 	echo "Usage: $progname <pattern>"
 	echo "Ex:    $progname ^gnome"
 	exit 0
 fi
 
+if [ "$1" = "--version" -o "$1" = "-v" ]; then
+	echo "$progname version $version"
+	echo "Copyright (C) 2006-2007 Dan McGee"
+	exit 0
+fi
+
+if [ -z "$1" -o "${1:0:1}" = "-" ]; then
+	echo "Usage: $progname <pattern>"
+	echo "Ex:    $progname ^gnome"
+	exit 1
+fi
+
+echo "debug 1"
 # Make two temp files and send output of commands to these files
 querydump=$(mktemp)
 pacman -Qs $1 > $querydump
 syncdump=$(mktemp)
 pacman -Ss $1 > $syncdump
+echo "debug 2"
 
 # Strip descriptions and 'local/' from -Qs query
 instpkg=$(mktemp)
 egrep '^[^ ]' $querydump | sed -e 's@^local/@@' > $instpkg
+echo "debug 3"
 
 # Add pkgs not in sync db, mark pkgs that are installed
 cat $instpkg | while read -r pkg; do
@@ -57,6 +73,7 @@
 	sed -i "s@^\(.\+/$pkg\)@\***\1@" $syncdump
 done
 
+echo "debug 4"
 # Print colorized package list and descriptions to screen
 echo -e "$(sed -r \
 	-e "s at current/.*@$CLR1&$BASE@" \
@@ -71,6 +88,7 @@
 	< $syncdump )"
 echo -en "\e[0m"
 
+echo "debug 5"
 rm $querydump
 rm $syncdump
 rm $instpkg
Index: pacman-lib/src/pacman/query.c
diff -u pacman-lib/src/pacman/query.c:1.27 pacman-lib/src/pacman/query.c:1.28
--- pacman-lib/src/pacman/query.c:1.27	Mon Mar  5 17:13:35 2007
+++ pacman-lib/src/pacman/query.c	Tue Mar  6 17:06:28 2007
@@ -92,7 +92,7 @@
 	if(config->op_q_search) {
 		alpm_list_t *ret = alpm_db_search(db_local, targets);
 		if(ret == NULL) {
-			return(1);
+			return(0);
 		}
 		for(i = ret; i; i = alpm_list_next(i)) {
 			char *group = NULL;




More information about the pacman-dev mailing list