From 63b1df99668455ff5ec9c0caa081e86d999b9dc6 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Wed, 23 Mar 2016 16:01:20 -0700 Subject: [PATCH] Print usage message when cl arg parsing fails Summary:public D2987288 introduced a regression where usage messages were no longer printed, and instead exceptions went uncaught. Reviewed By: jeremydubreil Differential Revision: D3089620 fb-gh-sync-id: 1cca0c6 shipit-source-id: 1cca0c6 --- infer/src/backend/utils.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/infer/src/backend/utils.ml b/infer/src/backend/utils.ml index 2deb3f9bd..8f02b845f 100644 --- a/infer/src/backend/utils.ml +++ b/infer/src/backend/utils.ml @@ -868,7 +868,11 @@ module Arg = struct let parse env_var spec anon usage = let env_args = env_to_argv (try Unix.getenv env_var with Not_found -> "") in let env_cl_args = prepend_to_argv env_args in - Arg.parse_argv (Array.of_list env_cl_args) spec anon usage + try + Arg.parse_argv (Array.of_list env_cl_args) spec anon usage + with + | Bad usage -> Pervasives.prerr_string usage; exit 2; + | Help usage -> Pervasives.print_string usage; exit 0; end