Skip to contentSkip to conversation

update-alternatives: Installing fails for "["

PATCH Applied Liu Jian 2 participants 3 messages Oct 30, 2014 – Oct 31, 2014

lore
Share & tools
lore

Liu Jian

author
#0 lore raw

PATCH 1/1 update-alternatives: Installing fails for "["

From 6431466b7c3f5fe76720372593fc785b572db84c Mon Sep 17 00:00:00 2001
From: Jian Liu <[email protected]>
Date: Wed, 29 Oct 2014 09:58:14 +0800
Subject: [opkg-utils PATCH] update-alternatives: Installing fails for "["

Insalling packages using update-alternatives will give the following error lines:
sed: -e expression #1, char 41: unterminated address regex
sed: -e expression #1, char 42: unterminated address regex
This is caused by the script update-alternatives.
"[" can not be used directly in sed expression, which should be escaped in sed expression.

---
 update-alternatives |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
update-alternatives +5 -1
index c332309..8916cbd 100644
@@ -68,6 +68,10 @@ protect_slashes() {
 	sed -e 's/\//\\\//g'
 }
 
+protect_special_character() {
+	sed -e 's/\[/\\\[/g'
+}
+
 remove_alt() {
 	[ $# -lt 2 ] && return 1
 	local name="$1"
@@ -75,7 +79,7 @@ remove_alt() {
 
 	[ ! -f $ad/$name ] && return 0
 
-	path=`echo $path | protect_slashes`
+	path=`echo $path | protect_slashes | protect_special_character`
 	sed -ne "/^$path\>.*/!p" $ad/$name > $ad/$name.new
 	mv $ad/$name.new $ad/$name
 }
Signature · 1 line
1.7.0.5
author
#1 lore raw

Insalling packages using update-alternatives will give the following error lines:
sed: -e expression #1, char 41: unterminated address regex
sed: -e expression #1, char 42: unterminated address regex This is caused by the script update-alternatives.
"[" can not be used directly in sed expression, which should be escaped in sed expression.

---
update-alternatives | 6 +++++-

1 files changed, 5 insertions(+), 1 deletions(-)

----- I add the head of this patch -----

于 2014年10月30日 13:40, Liu Jian 写道:

Signature · 3 lines
Jian Liu
Email: [email protected]
Office Phone: 86-10-84778539
Applied
#2 lore raw
Quoted 8 lines · Liu Jian

Insalling packages using update-alternatives will give the following error lines:
sed: -e expression #1, char 41: unterminated address regex
sed: -e expression #1, char 42: unterminated address regex This is caused by the script update-alternatives.
"[" can not be used directly in sed expression, which should be escaped in sed expression.

Quoted 4 lines

---
update-alternatives | 6 +++++-

1 files changed, 5 insertions(+), 1 deletions(-)

I've merged this to opkg-utils, many thanks!

I'm about to send a patch for openembedded-core which updates the opkg-utils SRCREV to use this new commit.

Signature · 4 lines
Paul Barker

Email: [email protected]
http://www.paulbarker.me.uk