src/Pure/ML-Systems/alice.ML
changeset 26220 d34b68c21f9a
parent 26084 a7475459c740
child 26226 7ddf8a34dbd5
equal deleted inserted replaced
26219:2d026932f710 26220:d34b68c21f9a
     9 $ env ALICE_JIT_MODE=0 alice
     9 $ env ALICE_JIT_MODE=0 alice
    10 - val ml_system = "alice";
    10 - val ml_system = "alice";
    11 - use "ML-Systems/exn.ML";
    11 - use "ML-Systems/exn.ML";
    12 - use "ML-Systems/multithreading.ML";
    12 - use "ML-Systems/multithreading.ML";
    13 - use "ML-Systems/time_limit.ML";
    13 - use "ML-Systems/time_limit.ML";
       
    14 - use "ML-Systems/system_shell.ML";
    14 - use "ML-Systems/alice.ML";
    15 - use "ML-Systems/alice.ML";
    15 - use "ROOT.ML";
    16 - use "ROOT.ML";
    16 - Session.finish ();
    17 - Session.finish ();
    17 *)
    18 *)
    18 
    19 
   141 
   142 
   142 
   143 
   143 
   144 
   144 (** OS related **)
   145 (** OS related **)
   145 
   146 
   146 (* current directory *)
       
   147 
       
   148 val cd = OS.FileSys.chDir;
   147 val cd = OS.FileSys.chDir;
   149 val pwd = OS.FileSys.getDir;
   148 val pwd = OS.FileSys.getDir;
   150 
   149 
   151 
       
   152 (* system command execution *)
       
   153 
       
   154 (*execute Unix command which doesn't take any input from stdin and
       
   155   sends its output to stdout; could be done more easily by Unix.execute,
       
   156   but that function doesn't use the PATH*)
       
   157 fun execute command =
       
   158   let
       
   159     val tmp_name = OS.FileSys.tmpName ();
       
   160     val is = (OS.Process.system (command ^ " > " ^ tmp_name); TextIO.openIn tmp_name);
       
   161     val result = TextIO.inputAll is;
       
   162   in
       
   163     TextIO.closeIn is;
       
   164     OS.FileSys.remove tmp_name;
       
   165     result
       
   166   end;
       
   167 
       
   168 (*plain version; with return code*)
       
   169 val system = OS.Process.system: string -> int;
   150 val system = OS.Process.system: string -> int;
   170 
   151 
   171 structure OS =
   152 structure OS =
   172 struct
   153 struct
   173   open OS;
   154   open OS;
   180     val compare = Int.compare;
   161     val compare = Int.compare;
   181     open FileSys;
   162     open FileSys;
   182   end;
   163   end;
   183 end;
   164 end;
   184 
   165 
   185 
       
   186 (* getenv *)
       
   187 
       
   188 fun getenv var =
   166 fun getenv var =
   189   (case OS.Process.getEnv var of
   167   (case OS.Process.getEnv var of
   190     NONE => ""
   168     NONE => ""
   191   | SOME txt => txt);
   169   | SOME txt => txt);