Gentoo Archives: gentoo-dev

From: Ulrich Mueller <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] escaping variables in sed expressions
Date: Tue, 15 Apr 2008 13:10:28
Message-Id: 18436.43326.943933.835176@a1ihome1.kph.uni-mainz.de
In Reply to: [gentoo-dev] escaping variables in sed expressions by "Marijn Schouten (hkBst)"
1 >>>>> On Tue, 15 Apr 2008, Marijn Schouten (hkBst) wrote:
2
3 > There are several option to handle this. I could use a less common
4 > delimiter or I could escape it: ${D//_/\_} instead of ${D}. I could
5 > use a sed expression that doesn't suffer from this problem (thanks
6 > to dleverton):
7
8 > sed -ne '\_^prefix = /usr/local_!{p;d}' -e "iprefix = ${D}" -i Makefile
9
10 Hi Marijn,
11
12 both approaches won't work since you would have to escape not only the
13 pattern delimiter, but also sed special characters (like "\" and "&")
14 _and_ make special characters (e.g. the dollar sign).
15
16 Probably better to pass it to make via a command argument or
17 environment variable.
18
19 Ulrich
20 --
21 gentoo-dev@l.g.o mailing list