aboutsummaryrefslogtreecommitdiffstats
path: root/driver/Commandline.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2019-05-06 17:07:24 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2019-05-10 14:30:37 +0200
commitb49feed2f88c0a6ae9cc2ca4b2982096f18a2112 (patch)
treea00311d29d497a43fbf410ad56073739808c1f6f /driver/Commandline.ml
parent47c86d46a329ee2c4c26a82b29edd40bb4b4c35c (diff)
downloadcompcert-kvx-b49feed2f88c0a6ae9cc2ca4b2982096f18a2112.tar.gz
compcert-kvx-b49feed2f88c0a6ae9cc2ca4b2982096f18a2112.zip
Expand the responsefiles earlier
* Move the expansion of response files to module Commandline, during the initialization of `Commandline.argv`. This way we're sure it's done exactly once. * Make `Commandline.argv` a `string array` instead of a `string array ref`. We no longer need to update it after initialization! * Improve reporting of errors during expansion of response files.
Diffstat (limited to 'driver/Commandline.ml')
-rw-r--r--driver/Commandline.ml14
1 files changed, 7 insertions, 7 deletions
diff --git a/driver/Commandline.ml b/driver/Commandline.ml
index 75ca1683..672ed834 100644
--- a/driver/Commandline.ml
+++ b/driver/Commandline.ml
@@ -16,7 +16,6 @@
(* Parsing of command-line flags and arguments *)
open Printf
-open Responsefile
type pattern =
| Exact of string
@@ -114,14 +113,15 @@ let parse_array spec argv first last =
end
in parse first
-let argv : string array ref = ref [||]
+let argv =
+ try
+ Responsefile.expandargv Sys.argv
+ with Responsefile.Error msg | Sys_error msg ->
+ eprintf "Error while processing the command line: %s\n" msg;
+ exit 2
let parse_cmdline spec =
- try
- argv := expandargv Sys.argv;
- parse_array spec !argv 1 (Array.length !argv - 1)
- with Responsefile.Error s ->
- raise (CmdError s)
+ parse_array spec argv 1 (Array.length argv - 1)
let long_int_action key s =
let ls = String.length s