From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] guix-package: Add '--search'. Date: Sat, 26 Jan 2013 22:43:56 +0100 Message-ID: <871ud7d3hf.fsf@gnu.org> References: <87libor1c9.fsf@karetnikov.org> <87r4lfr0r3.fsf@karetnikov.org> <87obgi6v7f.fsf@gnu.org> <87r4lb29sy.fsf@karetnikov.org> <87ip6mjnbv.fsf@gnu.org> <87622kuxu2.fsf_-_@karetnikov.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:54349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzDXb-0000QK-VO for bug-guix@gnu.org; Sat, 26 Jan 2013 16:44:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TzDXa-0008Ko-Jv for bug-guix@gnu.org; Sat, 26 Jan 2013 16:43:59 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:24586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzDXa-0008KV-Dm for bug-guix@gnu.org; Sat, 26 Jan 2013 16:43:58 -0500 In-Reply-To: <87622kuxu2.fsf_-_@karetnikov.org> (Nikita Karetnikov's message of "Sat, 26 Jan 2013 03:56:04 -0500") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Nikita Karetnikov Cc: bug-guix@gnu.org Nikita Karetnikov skribis: >> (if (or (and=3D> (package-synopsis package) >> (compose matches? gettext)) > > I came up with a different solution, which seems more readable. What > do you think? (If you want, I'll use your version.) [...] > From 0083eff18eb584213f55974807d4e0e6e29d3c73 Mon Sep 17 00:00:00 2001 > From: Nikita Karetnikov > Date: Sat, 26 Jan 2013 08:36:31 +0000 > Subject: [PATCH] guix-package: Add '--search'. > > * guix-package.in (find-packages-by-description): New procedure. > (show-help, %options): Add '--search'. > (guix-package)[process-query]: Add support for '--search'. > * doc/guix.texi (Invoking guix-package): Document it. > * tests/guix-package.sh: Add tests. [...] > +@item --search=3D@var{regexp} > +@itemx -s @var{regexp} > +Search in the @emph{synopsis} and @emph{description} fields of the > +available packages. And list the ones that match @var{regexp}. Rather: List the available packages whose synopsis or description matches @var{regexp}. (The end-user shouldn=E2=80=99t have to think in terms of structure fields.) > + (delete-duplicates > + (sort > + (fold-packages (lambda (package result) > + (if (any (lambda (f) > + (false-if-exception > + (regexp-exec rx (gettext (f package))))) > + (list package-synopsis package-description= )) > + (cons package result) > + result)) > + '()) I still prefer the solution that avoids =E2=80=98false-if-exception=E2=80= =99, because =E2=80=98false-if-exception=E2=80=99 could hide real issues other than wron= g-type-arg. > + # Search. > + echo "Testing 'search'..." > + if test "`guix-package -s "GNU Hello" | cut -f1`" =3D "hello"; > + then echo "Test1: OK"; else echo "Test1: failed"; fi > + > + if test "`guix-package -s "n0t4r341p4ck4g3"`" =3D ""; > + then echo "Test2: OK"; else echo "Test2: failed"; fi Please remove the =E2=80=98echo=E2=80=99 and =E2=80=98if=E2=80=99: it=E2=80= =99s in a =E2=80=98set -x=E2=80=99 so everything gets written to guix-package.log, and it=E2=80=99s in a =E2=80=98set -e=E2=80=99= so any non-zero exit causes a test failure. You can commit once those tiny issues are fixed. Thank you! Ludo=E2=80=99.