From 8d3d5a52d2746af91f770608cce5f47462f33aba Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 17 Apr 2012 14:54:48 +0100 Subject: sparsify: Fix comma/colon and quoting in qemu-img command. Colon characters are not allowed in qemu/qemu-img filenames. There's no way to quote them. Comma characters CAN be used. However they must be quoted (by doubling) when used in the '-o' option. Fix general quoting problems in the external command. --- sparsify/utils.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sparsify/utils.ml') diff --git a/sparsify/utils.ml b/sparsify/utils.ml index e34fe403..d2be12c8 100644 --- a/sparsify/utils.ml +++ b/sparsify/utils.ml @@ -76,6 +76,16 @@ let rec string_find s sub = in loop 0 +let rec replace_str s s1 s2 = + let len = String.length s in + let sublen = String.length s1 in + let i = string_find s s1 in + if i = -1 then s + else ( + let s' = String.sub s 0 i in + let s'' = String.sub s (i+sublen) (len-i-sublen) in + s' ^ s2 ^ replace_str s'' s1 s2 + ) let string_random8 = let chars = "abcdefghijklmnopqrstuvwxyz0123456789" in fun () -> -- cgit