Skip to content

Commit df44759

Browse files
committed
make command line parsing a bit forgiving
1 parent b6a7a00 commit df44759

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

jscomp/main/js_main.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,15 @@ let buckle_script_flags : (string * Arg.spec * string) list =
357357
let file_level_flags_handler (e : Parsetree.expression option) =
358358
match e with
359359
| None -> ()
360-
| Some {pexp_desc = Pexp_array args } ->
360+
| Some {pexp_desc = Pexp_array args ; pexp_loc} ->
361361
let args = Array.of_list
362362
(Sys.executable_name :: Ext_list.map args (fun e ->
363363
match e.pexp_desc with
364364
| Pexp_constant (Pconst_string(name,_)) -> name
365365
| _ -> Location.raise_errorf ~loc:e.pexp_loc "string literal expected" )) in
366-
Arg.parse_argv ~current:(ref 0)
366+
(try Arg.parse_argv ~current:(ref 0)
367367
args buckle_script_flags ignore usage
368+
with _ -> Location.prerr_warning pexp_loc (Preprocessor "invalid flags for bsc"))
368369
(* ;Format.fprintf Format.err_formatter "%a %b@."
369370
Ext_obj.pp_any args !Js_config.cross_module_inline; *)
370371
| Some e ->

lib/4.06.1/whole_compiler.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420763,14 +420763,15 @@ let buckle_script_flags : (string * Arg.spec * string) list =
420763420763
let file_level_flags_handler (e : Parsetree.expression option) =
420764420764
match e with
420765420765
| None -> ()
420766-
| Some {pexp_desc = Pexp_array args } ->
420766+
| Some {pexp_desc = Pexp_array args ; pexp_loc} ->
420767420767
let args = Array.of_list
420768420768
(Sys.executable_name :: Ext_list.map args (fun e ->
420769420769
match e.pexp_desc with
420770420770
| Pexp_constant (Pconst_string(name,_)) -> name
420771420771
| _ -> Location.raise_errorf ~loc:e.pexp_loc "string literal expected" )) in
420772-
Arg.parse_argv ~current:(ref 0)
420772+
(try Arg.parse_argv ~current:(ref 0)
420773420773
args buckle_script_flags ignore usage
420774+
with _ -> Location.prerr_warning pexp_loc (Preprocessor "invalid flags for bsc"))
420774420775
(* ;Format.fprintf Format.err_formatter "%a %b@."
420775420776
Ext_obj.pp_any args !Js_config.cross_module_inline; *)
420776420777
| Some e ->

0 commit comments

Comments
 (0)