Gentoo Archives: gentoo-catalyst

From: Matt Turner <mattst88@g.o>
To: gentoo-catalyst@l.g.o
Cc: "W. Trevor King" <wking@×××××××.us>
Subject: Re: [gentoo-catalyst] [PATCH] livecdfs-update.sh: Escape ampersands in STARTX sed expression
Date: Sat, 09 Mar 2013 02:48:02
Message-Id: CAEdQ38FBzmOo-9PFC6nY1H8Jfz0sKekXGXhtYSSJExXcOYyRLw@mail.gmail.com
In Reply to: [gentoo-catalyst] [PATCH] livecdfs-update.sh: Escape ampersands in STARTX sed expression by "W. Trevor King"
1 On Sun, Mar 3, 2013 at 8:53 AM, W. Trevor King <wking@×××××××.us> wrote:
2 > From: "W. Trevor King" <wking@×××××××.us>
3 >
4 > From sed(1):
5 >
6 > s/regexp/replacement/
7 > Attempt to match regexp against the pattern space. If successful,
8 > replace that portion matched with replacement. The replacement
9 > may contain the special character & to refer to that portion of
10 > the pattern space which matched, and the special escapes \1
11 > through \9 to refer to the corresponding matching sub-expressions
12 > in the regexp.
13 >
14 > This means that the old expression (with unescaped ampersands) lead
15 > to:
16 >
17 > source /etc/profile ##STARTX##STARTX su - ${first_user} -c startx
18 >
19 > when we want:
20 >
21 > source /etc/profile && su - ${first_user} -c startx
22 >
23 > with ${first_user} expanded in both cases.
24 > ---
25 > targets/support/livecdfs-update.sh | 2 +-
26 > 1 file changed, 1 insertion(+), 1 deletion(-)
27 >
28 > diff --git a/targets/support/livecdfs-update.sh b/targets/support/livecdfs-update.sh
29 > index 77d694e..fda3e36 100644
30 > --- a/targets/support/livecdfs-update.sh
31 > +++ b/targets/support/livecdfs-update.sh
32 > @@ -389,7 +389,7 @@ esac
33 > if [ -e /etc/startx ]
34 > then
35 > sed -i \
36 > - "s:##STARTX:source /etc/profile && su - ${first_user} -c startx:" \
37 > + "s:##STARTX:source /etc/profile \&\& su - ${first_user} -c startx:" \
38 > /root/.bashrc
39 > fi
40 >
41 > --
42 > 1.8.2.rc0.16.g20a599e
43 >
44 >
45
46 Nice. Bug since 2006. I've committed this. Thanks!

Replies