Commit Diff


commit - cc5596d8c4a9f7e1fc5a632e5093e23f4fb80cb5
commit + 432c637b8849b493bbe9a6907f2adc9e3d6d9c32
blob - 65a9f185b733ac69b17f431f15d4b32cdf4e238a
blob + 2acacf973e376511c10a697abac71b65f8c16ba2
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
@@ -71,20 +71,28 @@ sed()
 	#
 	# Therefore, scan the argument list and remove "-i ''", replacing it
 	# with just "-i".
+
+	original_cmd="$@"
 	[ "$PLATFORM" = "linux" ] && {
 		set -- "$@"
-		i=1
-		while [ "$i" -le "$#" ]; do
-			m=$((i + 1))
-			[ "${!i}" = "-i" ] && [ -z "${!m}" ] && {
+
+		for w in "$@"
+		do
+			[ "$w" = "-i" ] && {
+				seen=1
+				continue
+			}
+
+			[ "$seen" = "1" -a -z "$w" ] && {
+				# Move past -i and ''
 				shift 2
-				command "$SEDCMD" -i "$@"
+
+				command "$SEDCMD" -i $@
 				return
 			}
-			i=$((i + 1))
 		done
 	}
-	command "$SEDCMD" "$@"
+	command "$SEDCMD" $original_cmd
 }