Commits

Peter Szilagyi committed e3df298

fixed a case error in omake/Env.set_env

  • Participants
  • Parent commits a138e31

Comments (0)

Files changed (1)

File ocaml/omake/env.ml

 
 let create_default id =
   let t = Config.create () in
-  save id t;
+  ignore id;
   t
 
 let get id =
     begin
       match Config.read_file file with
       | Ok t ->
-        save id t;
         t
       | Error exn ->
         Log.printf
-          "Can't read env file for %s (%s).  Writing new file."
+          "Can't read env file for %s (%s)."
           (Id.to_string id)
           (Exn.to_string exn);
-        create_default id
+	create_default id
     end
   else
     create_default id
 let remove id x =
   let t = get id in
   let key = var_to_string x in
-  Config.remove t key
+  Config.remove t key;
+  save id t
 
 (* Set the variables before starting the process. *)
 let set_env t =
-  Config.iter t ~f:(fun ~key ~value ->
-    (* See the CRs in config.ml.  This effectively does String.uppercase. *)
-    let key = var_to_string (var_of_string key) in
-    Unix.putenv ~key ~data:value)
+  (* We could alternatively [Config.iter t] and [String.uppercase] the names.  That would
+     be good in the sense that we could eliminate [all_vars]. *)
+  List.iter all_vars ~f:(fun var ->
+    let key = var_to_string var in
+    if Config.mem t key then
+      Unix.putenv ~key ~data:(Config.lookup t ~key ~default:""))