From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Jlj7k-0007QB-Ls for garchives@archives.gentoo.org; Tue, 15 Apr 2008 11:14:52 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A4236E05EC; Tue, 15 Apr 2008 11:14:50 +0000 (UTC) Received: from amun.cheops.ods.org (amun.cheops.ods.org [82.95.138.191]) by pigeon.gentoo.org (Postfix) with ESMTP id 6E4A8E05ED for ; Tue, 15 Apr 2008 11:14:50 +0000 (UTC) Received: from tefnut.cheops.ods.org ([2001:888:1022:0:211:24ff:fe37:e46e] helo=gentoo.org) by amun.cheops.ods.org with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Jlj7f-00085s-Fo for gentoo-dev@lists.gentoo.org; Tue, 15 Apr 2008 13:14:49 +0200 Date: Tue, 15 Apr 2008 13:14:46 +0200 From: Fabian Groffen To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] escaping variables in sed expressions Message-ID: <20080415111445.GO979@gentoo.org> Mail-Followup-To: gentoo-dev@lists.gentoo.org References: <48048E31.6040209@gentoo.org> <3c32af40804150405qb2bbfbavb8d7ce575dbc2278@mail.gmail.com> 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-Disposition: inline In-Reply-To: <3c32af40804150405qb2bbfbavb8d7ce575dbc2278@mail.gmail.com> User-Agent: Mutt/1.5.17 (Darwin 8.11.0, VIM - Vi IMproved 7.1) Organization: Gentoo Foundation, Inc. X-Content-Scanned: by amun.cheops.ods.org (Exim Exiscan) using SpamAssassin and ClamAV X-Archives-Salt: d0f51454-33de-4e15-8e90-f8f55d1ff363 X-Archives-Hash: ea215132a78ff908c51500287aa1a952 On 15-04-2008 13:05:26 +0200, Santiago M. Mola wrote: > On Tue, Apr 15, 2008 at 1:14 PM, Marijn Schouten (hkBst) > wrote: > > > > Hi list, > > > > it seems I have been using some fragile sed expression and I'd like to tap > > the collective > > wisdom for avoiding doing that in the future. > > > > dev-scheme/slib-3.1.5-r1 currently does > > > > sed "s_prefix = /usr/local/_prefix = ${D}/usr/_" -i Makefile > > > > to make it not violate the sandbox. However a user had set > > PORTAGE_TMPDIR=/home/gentoo_overflow/tmp causing the sed expression to > > contain too may > > underscores and failing.[1] > > > > There are several option to handle this. I could use a less common > > delimiter or I could > > escape it: ${D//_/\_} instead of ${D}. I could use a sed expression that > > doesn't suffer > > from this problem (thanks to dleverton): > > > > sed -ne '\_^prefix = /usr/local_!{p;d}' -e "iprefix = ${D}" -i Makefile > > > > Comments? > > > > Currently is use ':' as sed delimiter when paths are involved. I'd > also like to hear from you about proper delimiters if you think ':' is > not safe enough. I met one case where : was indeed a problem, but that was in CFLAGS/LDFLAGS replacements. Some linkers accept (and do require) arguments that are like "-mg:2512s". > AFAIK, the only corner case which would make this fail would be > Windows paths (C:/gentoo-prefix). C:\ iirc, but Cygwin seems to map this as /cygdrive/C, Interix as /dev/fs/C, command prompt I have no clue how portage could ever normally work there. SpikeSource's SpikeWAMP uses Cygwin underneath, so Portage/ebuilds will see the mapped paths only, never heard of any problems from them regarding this either. -- Fabian Groffen Gentoo on a different level -- gentoo-dev@lists.gentoo.org mailing list