Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Apr 2002 19:27:28 -0700
From:      John De Boskey <jwd@FreeBSD.org>
To:        Ports List <freebsd-ports@FreeBSD.org>
Subject:   protect 'make search' key from options processing
Message-ID:  <20020416192727.A59133@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
Hi,

   I just ran into a small quirk running some make search's
in /usr/ports.

   Basically, we need to protect the key value from being
option processed by grep. A simple patch to add '--':


Index: bsd.port.subdir.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.subdir.mk,v
retrieving revision 1.41
diff -u -r1.41 bsd.port.subdir.mk
--- bsd.port.subdir.mk	23 Dec 2001 11:11:40 -0000	1.41
+++ bsd.port.subdir.mk	17 Apr 2002 02:12:43 -0000
@@ -255,7 +255,7 @@
 	top=`pwd`; \
 	there=`echo "$$here/" | sed s%$$top%${PORTSDIR}%`; \
 	if [ -n "$$key" ]; then \
-	  grep $$there ${PORTSDIR}/INDEX | grep -i "${key}" | awk -F\| '{ printf("Port:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9); }'; \
+	  grep $$there ${PORTSDIR}/INDEX | grep -i -- "${key}" | awk -F\| '{ printf("Port:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9); }'; \
 	elif [ $$name ]; then \
 	  grep $$there ${PORTSDIR}/INDEX | grep -i "^[^|]*${name}[^|]*|" | awk -F\| '{ printf("Port:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9); }'; \
 	else \


   I'd be happy to commit this, but I don't poke around in
the usr ports infrastructure enough to know if this might
break some assumed parsing in another script somewhere.

   Comments?

Thanks,
John

ps: to replicate

    cd /usr/ports && make search key=-php_doc

    to find the different languages the doc has been translated to.

    something like key='[a-z]*-php' will work, but I don't expect the
    average user to understand all the in's and out's of regular
    expressions, thus the patch to simply protect the '-' character.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020416192727.A59133>