author | wenzelm |
Mon, 22 Feb 2021 16:58:56 +0100 | |
changeset 73280 | a96944cbaf7d |
parent 73278 | 7dbae202ff84 |
child 73281 | 22417b631453 |
permissions | -rw-r--r-- |
73275 | 1 |
(* Title: Pure/System/process_result.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Result of system process. |
|
5 |
*) |
|
6 |
||
7 |
signature PROCESS_RESULT = |
|
8 |
sig |
|
9 |
type T |
|
10 |
val make: |
|
11 |
{rc: int, |
|
12 |
out_lines: string list, |
|
13 |
err_lines: string list, |
|
14 |
timing: Timing.timing} -> T |
|
15 |
val rc: T -> int |
|
16 |
val out_lines: T -> string list |
|
17 |
val err_lines: T -> string list |
|
18 |
val timing: T -> Timing.timing |
|
19 |
val out: T -> string |
|
20 |
val err: T -> string |
|
21 |
val ok: T -> bool |
|
22 |
val check: T -> T |
|
23 |
end; |
|
24 |
||
25 |
structure Process_Result: PROCESS_RESULT = |
|
26 |
struct |
|
27 |
||
28 |
abstype T = |
|
29 |
Process_Result of |
|
30 |
{rc: int, |
|
31 |
out_lines: string list, |
|
32 |
err_lines: string list, |
|
33 |
timing: Timing.timing} |
|
34 |
with |
|
35 |
||
36 |
val make = Process_Result; |
|
37 |
fun rep (Process_Result args) = args; |
|
38 |
||
39 |
val rc = #rc o rep; |
|
40 |
val out_lines = #out_lines o rep; |
|
41 |
val err_lines = #err_lines o rep; |
|
42 |
val timing = #timing o rep; |
|
43 |
||
73280 | 44 |
end; |
45 |
||
73277
0110e2e2964c
clarified signature: always trim_line of Process_Result.out/err, uniformly in ML and Scala;
wenzelm
parents:
73275
diff
changeset
|
46 |
val out = trim_line o cat_lines o out_lines; |
0110e2e2964c
clarified signature: always trim_line of Process_Result.out/err, uniformly in ML and Scala;
wenzelm
parents:
73275
diff
changeset
|
47 |
val err = trim_line o cat_lines o err_lines; |
73275 | 48 |
|
49 |
fun ok result = rc result = 0; |
|
50 |
||
73278
7dbae202ff84
clarified signature: Isabelle_System.bash_process is strict and thus cannot check for interrupt_return_code;
wenzelm
parents:
73277
diff
changeset
|
51 |
fun check result = if ok result then result else error (err result); |
73275 | 52 |
|
53 |
end; |