On Fri, Jul 15, 2022 at 08:36:19AM +0200, Laszlo Ersek wrote:
On 07/14/22 14:36, Richard W.M. Jones wrote:
Make it clearer what this function does and that it's potentially dangerous. The functionality itself is unchanged. --- mltools/on_exit.ml | 2 +- mltools/on_exit.mli | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mltools/on_exit.ml b/mltools/on_exit.ml index 53ccb68..9cdc496 100644 --- a/mltools/on_exit.ml +++ b/mltools/on_exit.ml @@ -102,7 +102,7 @@ let unlink filename = register (); List.push_front filename files
-let rmdir dir = +let rm_rf dir = register (); List.push_front dir rmdirs
diff --git a/mltools/on_exit.mli b/mltools/on_exit.mli index a02e3db..9bcf104 100644 --- a/mltools/on_exit.mli +++ b/mltools/on_exit.mli @@ -47,7 +47,7 @@ val f : (unit -> unit) -> unit val unlink : string -> unit (** Unlink a single temporary file on exit. *)
-val rmdir : string -> unit +val rm_rf : string -> unit (** Recursively remove a temporary directory on exit (using [rm -rf]). *)
val kill : ?signal:int -> int -> unit
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
[
Potential small improvement (separate, independent patch; feel free to push together with the rest, if you think it makes sense -- I didn't test it though, of course):
diff --git a/mltools/on_exit.ml b/mltools/on_exit.ml index 53ccb68ab0ce..a9e7f3201eba 100644 --- a/mltools/on_exit.ml +++ b/mltools/on_exit.ml @@ -52,7 +52,7 @@ let do_actions () = List.iter (do_action (fun file -> Unix.unlink file)) !files; List.iter (do_action ( fun dir -> - let cmd = sprintf "rm -rf %s" (Filename.quote dir) in + let cmd = sprintf "rm -rf -- %s" (Filename.quote dir) in ignore (Tools_utils.shell_command cmd) ) ) !rmdirs;
This would be to pacify my inner pedant. :) I don't expect "dir" to start with a hyphen, but this is supposed to be a generic function.
It's sensible just in case, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW