[Libguestfs] [PATCH 1/2] mllib: Add quote function to Common_utils module.

Richard W.M. Jones rjones at redhat.com
Thu Dec 8 13:01:52 UTC 2016


Remove multiple places where we let quote = Filename.quote
---
 builder/utils.ml                     | 2 --
 customize/customize_utils.ml         | 2 --
 dib/utils.ml                         | 2 --
 mllib/common_utils.ml                | 1 +
 mllib/common_utils.mli               | 3 +++
 mllib/curl.ml                        | 2 --
 sparsify/utils.ml                    | 2 --
 v2v/test-harness/v2v_test_harness.ml | 2 --
 v2v/utils.ml                         | 2 --
 v2v/utils.mli                        | 3 ---
 10 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/builder/utils.ml b/builder/utils.ml
index c5adff8..458edf9 100644
--- a/builder/utils.ml
+++ b/builder/utils.ml
@@ -30,8 +30,6 @@ and revision =
   | Rev_int of int
   | Rev_string of string
 
-let quote = Filename.quote
-
 let string_of_revision = function
   | Rev_int n -> string_of_int n
   | Rev_string s -> s
diff --git a/customize/customize_utils.ml b/customize/customize_utils.ml
index 29ae89b..feb4a16 100644
--- a/customize/customize_utils.ml
+++ b/customize/customize_utils.ml
@@ -21,5 +21,3 @@
 open Printf
 
 open Common_utils
-
-let quote = Filename.quote
diff --git a/dib/utils.ml b/dib/utils.ml
index 4026ee8..3775a41 100644
--- a/dib/utils.ml
+++ b/dib/utils.ml
@@ -21,8 +21,6 @@ open Common_utils
 
 open Printf
 
-let quote = Filename.quote
-
 let unit_GB howmany =
   (Int64.of_int howmany) *^ 1024_L *^ 1024_L *^ 1024_L
 
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index e1d1ab8..f4ddf01 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -234,6 +234,7 @@ module String = struct
 end
 
 let (//) = Filename.concat
+let quote = Filename.quote
 
 let ( +^ ) = Int64.add
 let ( -^ ) = Int64.sub
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index 7b142d4..4a6ddd6 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -113,6 +113,9 @@ end
 val ( // ) : string -> string -> string
 (** Concatenate directory and filename. *)
 
+val quote : string -> string
+(** Shell-safe quoting of a string (alias for {!Filename.quote}). *)
+
 val ( +^ ) : int64 -> int64 -> int64
 val ( -^ ) : int64 -> int64 -> int64
 val ( *^ ) : int64 -> int64 -> int64
diff --git a/mllib/curl.ml b/mllib/curl.ml
index baa75ec..fa37254 100644
--- a/mllib/curl.ml
+++ b/mllib/curl.ml
@@ -20,8 +20,6 @@ open Printf
 
 open Common_utils
 
-let quote = Filename.quote
-
 type t = {
   curl : string;
   args : args;
diff --git a/sparsify/utils.ml b/sparsify/utils.ml
index 9a49504..ba715f3 100644
--- a/sparsify/utils.ml
+++ b/sparsify/utils.ml
@@ -24,8 +24,6 @@ open Common_utils
 
 module G = Guestfs
 
-let quote = Filename.quote
-
 (* Return true if the filesystem is a read-only LV (RHBZ#1185561). *)
 let is_read_only_lv (g : G.guestfs) =
   let lvs = Array.to_list (g#lvs_full ()) in
diff --git a/v2v/test-harness/v2v_test_harness.ml b/v2v/test-harness/v2v_test_harness.ml
index b7f5e82..3c29a94 100644
--- a/v2v/test-harness/v2v_test_harness.ml
+++ b/v2v/test-harness/v2v_test_harness.ml
@@ -64,8 +64,6 @@ let default_plan = {
 
 let failwithf fs = ksprintf failwith fs
 
-let quote = Filename.quote
-
 let run ~test ?input_disk ?input_xml ?(test_plan = default_plan) () =
   let input_disk =
     match input_disk with
diff --git a/v2v/utils.ml b/v2v/utils.ml
index fb0b802..7485bf0 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -23,8 +23,6 @@ open Printf
 open Common_gettext.Gettext
 open Common_utils
 
-let quote = Filename.quote
-
 external drive_name : int -> string = "v2v_utils_drive_name"
 external drive_index : string -> int = "v2v_utils_drive_index"
 
diff --git a/v2v/utils.mli b/v2v/utils.mli
index 2bd1329..0a971d2 100644
--- a/v2v/utils.mli
+++ b/v2v/utils.mli
@@ -18,9 +18,6 @@
 
 (** Utilities used in virt-v2v only. *)
 
-val quote : string -> string
-(** The {!Filename.quote} function. *)
-
 val drive_name : int -> string
 val drive_index : string -> int
 
-- 
2.10.2




More information about the Libguestfs mailing list