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 <gentoo-dev+bounces-30275-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1Jliye-0006sW-7E
	for garchives@archives.gentoo.org; Tue, 15 Apr 2008 11:05:28 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id F099EE06F3;
	Tue, 15 Apr 2008 11:05:26 +0000 (UTC)
Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.248])
	by pigeon.gentoo.org (Postfix) with ESMTP id C7DCAE06F3
	for <gentoo-dev@lists.gentoo.org>; Tue, 15 Apr 2008 11:05:26 +0000 (UTC)
Received: by an-out-0708.google.com with SMTP id c8so547147ana.47
        for <gentoo-dev@lists.gentoo.org>; Tue, 15 Apr 2008 04:05:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth;
        bh=9JKhnZNCc5X/QN/vjBzPG/+OPCMoig/Md3mPxEORcWo=;
        b=gOGv6RXHyQ1FiuxsH4tM7o67vYX+BISYBKx0QW+42cj1w4QS1/oiY3HYYar7Hut8AeSCSX5VHJCrk6fYzlUhiJcIDluDArgGPFppgYfA1CyVG6Mjzn7Z1H2ONKQnxsfDkTVoVMd5jd+HYL8B5ALh4UjlQpOzhMbZ5OHs3KS3UPs=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth;
        b=hVovaIxkW2/XpbuUIPKTrRU7sp/fpiS+wylgN+7P6akQdsOU8qqGogok2sGnp5ls9pJ0COvkWU7OK5aGLgq+b3MWFAd2n1Wz5cE0csWt1B2kB7zMsSWb1WsjCgMfn/g+PnU0fqEsy0ZhavSJz87jFSlOEJaHwld8VIEHu8eozjY=
Received: by 10.100.58.19 with SMTP id g19mr14646170ana.44.1208257526550;
        Tue, 15 Apr 2008 04:05:26 -0700 (PDT)
Received: by 10.100.45.17 with HTTP; Tue, 15 Apr 2008 04:05:26 -0700 (PDT)
Message-ID: <3c32af40804150405qb2bbfbavb8d7ce575dbc2278@mail.gmail.com>
Date: Tue, 15 Apr 2008 13:05:26 +0200
From: "Santiago M. Mola" <coldwind@gentoo.org>
Sender: cooldwind@gmail.com
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] escaping variables in sed expressions
In-Reply-To: <48048E31.6040209@gentoo.org>
Precedence: bulk
List-Post: <mailto:gentoo-dev@lists.gentoo.org>
List-Help: <mailto:gentoo-dev+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-dev+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-dev+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-dev.gentoo.org>
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: 7bit
Content-Disposition: inline
References: <48048E31.6040209@gentoo.org>
X-Google-Sender-Auth: ff6c485f32cc7166
X-Archives-Salt: 036a8d1c-65e5-47ee-b1b4-064a9c52874b
X-Archives-Hash: 12a7125f53f2a506b7fe212467793635

On Tue, Apr 15, 2008 at 1:14 PM, Marijn Schouten (hkBst)
<hkBst@gentoo.org> 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.

AFAIK, the only corner case which would make this fail would be
Windows paths (C:/gentoo-prefix).

Regards,

-- 
Santiago M. Mola
Jabber ID: cooldwind@gmail.com
-- 
gentoo-dev@lists.gentoo.org mailing list