>From 6431466b7c3f5fe76720372593fc785b572db84c Mon Sep 17 00:00:00 2001
From: Jian Liu <jian....@windriver.com>
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.

Signed-off-by: Jian Liu <jian....@windriver.com>
---
 update-alternatives |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/update-alternatives b/update-alternatives
index c332309..8916cbd 100644
--- a/update-alternatives
+++ b/update-alternatives
@@ -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
 }
-- 
1.7.0.5

-- 
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to