[proaudio] [1341] make sed_check function more robust

[ Thread Index | Date Index | More lists.tuxfamily.org/proaudio Archives ]


Revision: 1341
Author:   evermind
Date:     2008-10-15 01:21:41 +0200 (Wed, 15 Oct 2008)

Log Message:
-----------
make sed_check function more robust

Modified Paths:
--------------
    trunk/overlays/proaudio/eclass/exteutils.eclass


Modified: trunk/overlays/proaudio/eclass/exteutils.eclass
===================================================================
--- trunk/overlays/proaudio/eclass/exteutils.eclass	2008-10-13 18:36:14 UTC (rev 1340)
+++ trunk/overlays/proaudio/eclass/exteutils.eclass	2008-10-14 23:21:41 UTC (rev 1341)
@@ -75,20 +75,32 @@
 	die_msg() {
 		eerror "failed to patch: ${1}"
 		eerror "Sed argument:"
-		eerror "sed ${args[@]}"
+		eerror "sed ${new_args[@]}"
 		die "sed patching failed"
 	}
 
 	local cnt=0
 	local args=("$@")
 	local uniq_backup="esed_bac${RANDOM}" # needed to find modified files
+	local new_args=""
 	for i in ${args[@]};do
-		if [ "$i" == "-i" ];then
-			args[$cnt]="-i${uniq_backup}"
+		if [ "${i::2}" == "-i" ];then
+			new_args[$cnt]="-i${uniq_backup}"
+
+			# eg if a switch like -ie is passed we've to separate em
+			if [ ! -z "${i:2}" ];then
+				let "cnt+=1"
+				new_args[$cnt]="-${i:2}"
+			fi
+		else
+			new_args[$cnt]="${i}"
 		fi
 		let "cnt+=1"
 	done
-	LC_ALL=C sed "${args[@]}"
+
+	# call sed to do the work
+	LC_ALL=C sed "${new_args[@]}"
+	
 	if [ "${?}" -ne "0" ] ;then
 		die_msg "retval not zero"
 	fi


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/