浏览代码

fixed expand_env (prevent too early replacement of %__file__%)

Nicolas Cannasse 13 年之前
父节点
当前提交
0a6856b542
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      main.ml

+ 1 - 1
main.ml

@@ -202,7 +202,7 @@ let delete_file f = try Sys.remove f with _ -> ()
 
 
 let expand_env path =
 let expand_env path =
 	let r = Str.regexp "%\\([A-Za-z0-9_]+\\)%" in
 	let r = Str.regexp "%\\([A-Za-z0-9_]+\\)%" in
-	Str.global_substitute r (fun s -> try Sys.getenv (Str.matched_group 1 s) with Not_found -> "") path
+	Str.global_substitute r (fun s -> let key = Str.matched_group 1 s in try Sys.getenv key with Not_found -> "%" ^ key ^ "%") path
 
 
 let unquote v =
 let unquote v =
 	let len = String.length v in
 	let len = String.length v in