From 07fb30b1618310e5a944a947499c4d121d8bd3d8 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 8 Dec 2016 12:49:38 +0000 Subject: [PATCH] mllib: Add quote function to Common_utils module. 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 c5adff855..458edf9a8 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 29ae89be8..feb4a1641 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 4026ee86d..3775a4153 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 e1d1ab83a..f4ddf0155 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 7b142d430..4a6ddd654 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 baa75ece2..fa37254b5 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 9a495041e..ba715f31f 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 b7f5e8276..3c29a9430 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 fb0b8027c..7485bf08a 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 2bd132905..0a971d2d8 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