From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1F0F3139694 for ; Wed, 19 Apr 2017 03:14:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4D67721C08B; Wed, 19 Apr 2017 03:14:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EBA0521C012 for ; Wed, 19 Apr 2017 03:14:40 +0000 (UTC) Received: from [192.168.1.6] (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 636FC3413B7; Wed, 19 Apr 2017 03:14:38 +0000 (UTC) Date: Wed, 19 Apr 2017 05:14:34 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <20170418223131.0f657dc2@symphony.aura-online.co.uk> References: <20170417215359.30641-1-chewi@gentoo.org> <20170417215359.30641-2-chewi@gentoo.org> <1492495724.1167.1.camel@gentoo.org> <20170418223131.0f657dc2@symphony.aura-online.co.uk> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [gentoo-dev] [PATCH 01/14] cdrom.eclass: Detect case-insensitively and handle special characters To: gentoo-dev@lists.gentoo.org,James Le Cuirot From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= Message-ID: <189A1488-2EFF-4CF5-BD50-E8FCD4BC3E23@gentoo.org> X-Archives-Salt: 306a1f77-43ef-442c-9a91-d87663f86afb X-Archives-Hash: cf5f0cd122e9646c1177e571ea3e881b Dnia 18 kwietnia 2017 23:31:31 CEST, James Le Cuirot n= apisa=C5=82(a): >On Tue, 18 Apr 2017 08:08:44 +0200 >Micha=C5=82 G=C3=B3rny wrote: > >> On pon, 2017-04-17 at 22:53 +0100, James Le Cuirot wrote: >> > diff --git a/eclass/cdrom=2Eeclass b/eclass/cdrom=2Eeclass >> > index 41488d2446c2=2E=2Ede72f15563db 100644 >> > --- a/eclass/cdrom=2Eeclass >> > +++ b/eclass/cdrom=2Eeclass >> > @@ -79,12 +79,13 @@ cdrom_get_cds() { >> > export CDROM_ROOT=3D${CD_ROOT_1:-${CD_ROOT}} >> > einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" >> > export CDROM_SET=3D-1 >> > - for f in ${CDROM_CHECK_1//:/ } ; do >> > + IFS=3D: =20 >>=20 >> 'local', please=2E > >This line disappears later in the series but I've amended it for the >history anyway=2E > >> > @@ -181,28 +182,24 @@ _cdrom_locate_file_on_cd() { >> > local showedmsg=3D0 showjolietmsg=3D0 >> > =20 >> > while [[ -z ${CDROM_ROOT} ]] ; do >> > - local i=3D0 >> > - local -a cdset=3D(${*//:/ }) >> > + local i=3D0 cdset >> > + IFS=3D: read -a cdset <<< "${*}" =20 >>=20 >> -r to avoid handling escapes; -d '' to avoid finishing on newline=2E > >Good call=2E > >> > @@ -243,4 +240,27 @@ _cdrom_locate_file_on_cd() { >> > done >> > } >> > =20 >> > +# @FUNCTION: _cdrom_glob_match >> > +# @USAGE: >> > +# @INTERNAL >> > +# @DESCRIPTION: >> > +# Locates the given path ($2) within the given root directory ($1) >> > +# case-insensitively and returns the first actual matching path=2E >This >> > +# eclass previously used "find -iname" but it only checked the >file >> > +# case-insensitively and not the directories=2E There is "find >-ipath" but >> > +# this does not intelligently skip non-matching paths, making it >> > +# slow=2E Case-insensitive matching can only be applied to patterns >so >> > +# extended globbing is used to turn regular strings into patterns=2E >All >> > +# special characters are escaped so don't worry about breaking >this=2E The >> > +# first person to make this work without an eval wins a cookie=2E >> > +_cdrom_glob_match() { >> > + local p=3D\?\($(sed -e 's:[^A-Za-z0-9/]:\\\0:g' -e 's:/:)/?(:g' <<< >"$2" || die)\) =20 >>=20 >> Explanatory comment needed, i=2Ee=2E what gets converted into what, and >why=2E > >I'll add this: > ># The following line turns this: ># foo*foo/bar bar/baz/file=2Ezip ># ># Into this: ># ?(foo\*foo)/?(bar\ bar)/?(baz)/?(file\=2Ezip) ># ># This turns every path component into an escaped extended glob ># pattern to allow case-insensitive matching=2E Globs cannot span ># directories so each component becomes an individual pattern=2E Why do you escape pattern chars? Wasn't the variable supposed to be a patt= ern in the first place? --=20 Best regards, Micha=C5=82 G=C3=B3rny (by phone) --=20 Best regards, Micha=C5=82 G=C3=B3rny (by phone)