Subject: regex in pkg_view
To: None <tech-pkg@NetBSD.org>
From: Min Sik Kim <minskim@NetBSD.org>
List: tech-pkg
Date: 05/31/2004 23:09:18
--Signature=_Mon__31_May_2004_23_09_18_-0500_Ltsh/3uWPb1M1+ry
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Hi,

The pkg_view command contains superfluous escape characters in regular
expressions.  See the following patch.

Index: pkg_view.sh
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/view/pkg_view.sh,v
retrieving revision 1.4
diff -u -r1.4 pkg_view.sh
--- pkg_view.sh	8 Sep 2003 07:09:34 -0000	1.4
+++ pkg_view.sh	1 Jun 2004 03:47:26 -0000
@@ -207,7 +207,7 @@
 		# a view.
 		#
 		case "$doit" in
-		"")	(cd ${depot_pkg_dbdir}/$1; $paxprog -rwpe '-s|\./\+VIEWS$||' '-s|\./\+REQUIRED_BY$||' ./+* ${pkg_dbdir}/$1)
+		"")	(cd ${depot_pkg_dbdir}/$1; $paxprog -rwpe '-s|\./+VIEWS$||' '-s|\./+REQUIRED_BY$||' ./+* ${pkg_dbdir}/$1)
 			$sedprog -e 's|'${depot_pkg_dbdir}/$1'|'${targetdir}'|g' < ${depot_pkg_dbdir}/$1/+CONTENTS > ${pkg_dbdir}/$1/+CONTENTS
 			echo "${depot_pkg_dbdir}/$1" > ${pkg_dbdir}/$1/+DEPOT
 			;;

Because '+' is not a special character in basic regular expressions,
it doesn't need to be escaped.  A problem is that some regex
implementations consider '\+' as two normal characters, '\' and '+',
while others consider it as '+'.  Is it okay to apply the patch above,
or is there any chance that the patch breaks yet another regex
implementation?

-- 
Min Sik Kim

--Signature=_Mon__31_May_2004_23_09_18_-0500_Ltsh/3uWPb1M1+ry
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iQEVAwUBQLwBbvQsKR/Zi7L+AQKQyAf+PlKdQoT25U0KGH45tChF3qPAdZeFOhYX
nukmIidKhU13RM6XhABltptB0BuKYJY2xNq4o4QrDFr1aV/M+O7FXfZQhMJsPW1p
cgDNDeSrwnRA+16QOscAQorn6bN2taEux8A4CReWio2auz57tas7Rqoja4MQ3J59
7HmBqPwEaya6RB0YUlZx/53j0knjJoHOl2uR6w9tMl/lZxfZETQ2SgcqxhiNafty
IHX42BTbEBMt/iNQk/o9uP1dUxW7fS7rf5UKCb9ncTn2KgbQCUKp7B53I/tKUiZT
GQ8UCNuJq2A6N8adCLpJbcvm/w8PClg1sVv17l7qPL+dsdAj8GuPpg==
=mgw9
-----END PGP SIGNATURE-----

--Signature=_Mon__31_May_2004_23_09_18_-0500_Ltsh/3uWPb1M1+ry--