Move the code executing cp in an helper function; just code motion. --- src/chroot.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/chroot.ml b/src/chroot.ml index d0ee4c3..b9c1dc2 100644 --- a/src/chroot.ml +++ b/src/chroot.ml @@ -23,6 +23,12 @@ open Utils open Package_handler let build_chroot debug files outputdir = + let do_copy src dest = + if debug >= 2 then printf "supermin: chroot: copy %s\n%!" dest; + let cmd = sprintf "cp -p %s %s" (quote src) (quote dest) in + ignore (Sys.command cmd) + in + List.iter ( fun file -> try @@ -59,9 +65,7 @@ let build_chroot debug files outputdir = symlink link opath | S_REG | S_CHR | S_BLK | S_FIFO | S_SOCK -> - if debug >= 2 then printf "supermin: chroot: copy %s\n%!" opath; - let cmd = sprintf "cp -p %s %s" (quote path) (quote opath) in - ignore (Sys.command cmd) + do_copy path opath with Unix_error _ -> () ) files; -- 2.1.0