src/Pure/System/isabelle_system.ML
changeset 73604 51b291ae3e2d
parent 73576 b50f8cc8c08e
child 73775 6bd747b71bd3
equal deleted inserted replaced
73603:342362c9496c 73604:51b291ae3e2d
     5 *)
     5 *)
     6 
     6 
     7 signature ISABELLE_SYSTEM =
     7 signature ISABELLE_SYSTEM =
     8 sig
     8 sig
     9   val bash_process: string -> Process_Result.T
     9   val bash_process: string -> Process_Result.T
       
    10   val bash_process_redirect: string -> Process_Result.T
    10   val bash_output: string -> string * int
    11   val bash_output: string -> string * int
    11   val bash: string -> int
    12   val bash: string -> int
    12   val bash_functions: unit -> string list
    13   val bash_functions: unit -> string list
    13   val check_bash_function: Proof.context -> string * Position.T -> string
    14   val check_bash_function: Proof.context -> string * Position.T -> string
    14   val absolute_path: Path.T -> string
    15   val absolute_path: Path.T -> string
    32 structure Isabelle_System: ISABELLE_SYSTEM =
    33 structure Isabelle_System: ISABELLE_SYSTEM =
    33 struct
    34 struct
    34 
    35 
    35 (* bash *)
    36 (* bash *)
    36 
    37 
    37 fun bash_process script =
    38 fun invoke_bash_process redirect script =
    38   Scala.function "bash_process"
    39   Scala.function "bash_process"
    39     ["export ISABELLE_TMP=" ^ Bash.string (getenv "ISABELLE_TMP"), script]
    40     [Value.print_bool redirect, "export ISABELLE_TMP=" ^ Bash.string (getenv "ISABELLE_TMP"), script]
    40   |> (fn [] => raise Exn.Interrupt
    41   |> (fn [] => raise Exn.Interrupt
    41       | [err] => error err
    42       | [err] => error err
    42       | a :: b :: c :: d :: lines =>
    43       | a :: b :: c :: d :: lines =>
    43           let
    44           let
    44             val rc = Value.parse_int a;
    45             val rc = Value.parse_int a;
    50               out_lines = out_lines,
    51               out_lines = out_lines,
    51               err_lines = err_lines,
    52               err_lines = err_lines,
    52               timing = {elapsed = elapsed, cpu = cpu, gc = Time.zeroTime}}
    53               timing = {elapsed = elapsed, cpu = cpu, gc = Time.zeroTime}}
    53          end
    54          end
    54       | _ => raise Fail "Malformed Isabelle/Scala result");
    55       | _ => raise Fail "Malformed Isabelle/Scala result");
       
    56 
       
    57 val bash_process = invoke_bash_process false;
       
    58 val bash_process_redirect = invoke_bash_process true;
    55 
    59 
    56 val bash = bash_process #> Process_Result.print #> Process_Result.rc;
    60 val bash = bash_process #> Process_Result.print #> Process_Result.rc;
    57 
    61 
    58 fun bash_output s =
    62 fun bash_output s =
    59   let
    63   let