From e9fe06d684b145a104cc319673076e069e853cac Mon Sep 17 00:00:00 2001 From: malc Date: Thu, 30 Jul 2015 21:08:03 +0300 Subject: [PATCH] More cosmetics --- utils.ml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/utils.ml b/utils.ml index 62d7f6e..cb6c56b 100644 --- a/utils.ml +++ b/utils.ml @@ -230,30 +230,30 @@ let fdcontents fd = loop () ;; -let getcmdoutput errstr cmd = - let error fmt = Printf.kprintf errstr fmt in +let getcmdoutput errfun cmd = + let reperror fmt = Printf.kprintf errfun fmt in let clofail s e = error "failed to close %s: %s" s e in match Unix.pipe () with | (exception exn) -> - error "pipe failed: %s" (exntos exn); + reperror "pipe failed: %s" (exntos exn); E.s | (r, w) -> match popen cmd [r, -1; w, 1] with | (exception exn) -> - error "failed to execute %S: %s" cmd (exntos exn); + reperror "failed to execute %S: %s" cmd (exntos exn); E.s | pid -> Ne.clo w @@ clofail "write end of the pipe"; let s = match Unix.waitpid [] pid with | (exception exn) -> - error "waitpid on %S %d failed: %s" cmd pid (exntos exn); + reperror "waitpid on %S %d failed: %s" cmd pid (exntos exn); E.s | _pid, Unix.WEXITED 0 -> begin match fdcontents r with | (exception exn) -> - error "failed to read output of %S: %s" cmd (exntos exn); + reperror "failed to read output of %S: %s" cmd (exntos exn); E.s | s -> let l = String.length s in @@ -262,13 +262,13 @@ let getcmdoutput errstr cmd = else s end; | _pid, Unix.WEXITED n -> - error "%S exited with error code %d" cmd n; + reperror "%S exited with error code %d" cmd n; E.s | _pid, Unix.WSIGNALED n -> - error "%S was killed with signal %d" cmd n; + reperror "%S was killed with signal %d" cmd n; E.s | _pid, Unix.WSTOPPED n -> - error "%S was stopped by signal %d" cmd n; + reperror "%S was stopped by signal %d" cmd n; E.s in Ne.clo r @@ clofail "read end of the pipe"; -- 2.11.4.GIT