src/Pure/System/ml_process.scala
changeset 62545 8ebffdaf2ce2
parent 62544 efa178abe023
child 62546 973b12bccbc5
equal deleted inserted replaced
62544:efa178abe023 62545:8ebffdaf2ce2
    64 
    64 
    65 
    65 
    66     // options
    66     // options
    67     val isabelle_process_options = Isabelle_System.tmp_file("options")
    67     val isabelle_process_options = Isabelle_System.tmp_file("options")
    68     File.write(isabelle_process_options, YXML.string_of_body(options.encode))
    68     File.write(isabelle_process_options, YXML.string_of_body(options.encode))
    69     val bash_env = Map("ISABELLE_PROCESS_OPTIONS" -> File.standard_path(isabelle_process_options))
    69     val env = Map("ISABELLE_PROCESS_OPTIONS" -> File.standard_path(isabelle_process_options))
    70     val eval_options = List("Options.load_default ()")
    70     val eval_options = List("Options.load_default ()")
    71 
    71 
    72     val eval_process =
    72     val eval_process =
    73       if (process_socket == "") Nil
    73       if (process_socket == "") Nil
    74       else List("Isabelle_Process.init " + ML_Syntax.print_string_raw(process_socket))
    74       else List("Isabelle_Process.init " + ML_Syntax.print_string_raw(process_socket))
    75 
    75 
       
    76     // bash
       
    77     val bash_args =
       
    78       Word.explode(Isabelle_System.getenv("ML_OPTIONS")) :::
       
    79       (eval_heaps ::: eval_exit ::: eval_secure ::: eval_modes ::: eval_options ::: eval_process).
       
    80         map(eval => List("--eval", eval)).flatten ::: args
    76     val bash_script =
    81     val bash_script =
    77       """
    82       """
    78         [ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle
    83         [ -z "$ISABELLE_TMP_PREFIX" ] && ISABELLE_TMP_PREFIX=/tmp/isabelle
    79 
    84 
    80         export ISABELLE_PID="$$"
    85         export ISABELLE_PID="$$"
    81         export ISABELLE_TMP="$ISABELLE_TMP_PREFIX$ISABELLE_PID"
    86         export ISABELLE_TMP="$ISABELLE_TMP_PREFIX$ISABELLE_PID"
    82         mkdir -p "$ISABELLE_TMP"
    87         mkdir -p "$ISABELLE_TMP"
    83         chmod $(umask -S) "$ISABELLE_TMP"
    88         chmod $(umask -S) "$ISABELLE_TMP"
    84 
    89 
    85         librarypath "$ML_HOME"
    90         librarypath "$ML_HOME"
    86         "$ML_HOME/poly" -q -i $ML_OPTIONS "$@"
    91         "$ML_HOME/poly" -q -i """ + File.bash_escape(bash_args) + """
    87         RC="$?"
    92         RC="$?"
    88 
    93 
    89         rm -f "$ISABELLE_PROCESS_OPTIONS"
    94         rm -f "$ISABELLE_PROCESS_OPTIONS"
    90         rmdir "$ISABELLE_TMP"
    95         rmdir "$ISABELLE_TMP"
    91 
    96 
    92         exit "$RC"
    97         exit "$RC"
    93       """
    98       """
    94 
    99 
    95     val bash_args =
   100     Bash.process(bash_script, env = env)
    96       List("-c", bash_script, "ml_process") :::
       
    97       (eval_heaps ::: eval_exit ::: eval_secure ::: eval_modes ::: eval_options ::: eval_process).
       
    98         map(eval => List("--eval", eval)).flatten ::: args
       
    99 
       
   100     Bash.process(null, bash_env, false, bash_args:_*)
       
   101   }
   101   }
   102 }
   102 }