Gentoo Archives: gentoo-dev

From: "Marijn Schouten (hkBst)" <hkBst@g.o>
To: "gentoo-dev@l.g.o" <gentoo-dev@l.g.o>
Subject: [gentoo-dev] escaping variables in sed expressions
Date: Tue, 15 Apr 2008 10:57:04
Message-Id: 48048E31.6040209@gentoo.org
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Hi list,
5
6 it seems I have been using some fragile sed expression and I'd like to tap the collective
7 wisdom for avoiding doing that in the future.
8
9 dev-scheme/slib-3.1.5-r1 currently does
10
11 sed "s_prefix = /usr/local/_prefix = ${D}/usr/_" -i Makefile
12
13 to make it not violate the sandbox. However a user had set
14 PORTAGE_TMPDIR=/home/gentoo_overflow/tmp causing the sed expression to contain too may
15 underscores and failing.[1]
16
17 There are several option to handle this. I could use a less common delimiter or I could
18 escape it: ${D//_/\_} instead of ${D}. I could use a sed expression that doesn't suffer
19 from this problem (thanks to dleverton):
20
21 sed -ne '\_^prefix = /usr/local_!{p;d}' -e "iprefix = ${D}" -i Makefile
22
23 Comments?
24
25 Marijn
26
27 [1]: http://bugs.gentoo.org/show_bug.cgi?id=217735
28
29 - --
30 Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
31 <http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
32 -----BEGIN PGP SIGNATURE-----
33 Version: GnuPG v2.0.9 (GNU/Linux)
34 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
35
36 iEYEARECAAYFAkgEjjEACgkQp/VmCx0OL2zGDQCcCcgx1/g/UXpB38HIjKjNhmL6
37 S4MAoK1aXJS6SW9FaZT4i2iaeo6AlD2u
38 =Id31
39 -----END PGP SIGNATURE-----
40 --
41 gentoo-dev@l.g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] escaping variables in sed expressions "Santiago M. Mola" <coldwind@g.o>
Re: [gentoo-dev] escaping variables in sed expressions David Leverton <levertond@××××××××××.com>
Re: [gentoo-dev] escaping variables in sed expressions Ulrich Mueller <ulm@g.o>
Re: [gentoo-dev] escaping variables in sed expressions "Petteri Räty" <betelgeuse@g.o>
Re: [gentoo-dev] escaping variables in sed expressions Mike Frysinger <vapier@g.o>