Gentoo Archives: gentoo-catalyst

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

Replies