diff options
author | Jean-Sébastien Pédron <[email protected]> | 2016-08-29 15:28:44 +0200 |
---|---|---|
committer | Jean-Sébastien Pédron <[email protected]> | 2016-09-08 13:46:15 +0200 |
commit | 6c546accfcb2ad6264c16f62e74d35367dabb72c (patch) | |
tree | f0c332430ef385489946bde4107fed92e953e6d1 /plugins/dialyzer.mk | |
parent | 8a20b423784a7ccf223dbabe4d78daa675823664 (diff) | |
download | erlang.mk-6c546accfcb2ad6264c16f62e74d35367dabb72c.tar.gz erlang.mk-6c546accfcb2ad6264c16f62e74d35367dabb72c.tar.bz2 erlang.mk-6c546accfcb2ad6264c16f62e74d35367dabb72c.zip |
dialyzer.mk: Use the shell to parse command line args
Splitting arguments on `-` was dangerous: if a path contained such a
character, it would be split and the second half thrown away by the
filtering.
Now, `$(ERLC_OPTS)` is passed to erl(1) after `-extra`. Thus
arguments parsing is done by the shell and we only have to call
init:get_plain_arguments/0 to get them as a list.
Diffstat (limited to 'plugins/dialyzer.mk')
-rw-r--r-- | plugins/dialyzer.mk | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/plugins/dialyzer.mk b/plugins/dialyzer.mk index 8c2710f..d66bcc0 100644 --- a/plugins/dialyzer.mk +++ b/plugins/dialyzer.mk @@ -27,14 +27,17 @@ help:: # Plugin-specific targets. define filter_opts.erl - Opts = binary:split(<<"$1">>, <<"-">>, [global]), - Filtered = lists:reverse(lists:foldl(fun - (O = <<"pa ", _/bits>>, Acc) -> [O|Acc]; - (O = <<"D ", _/bits>>, Acc) -> [O|Acc]; - (O = <<"I ", _/bits>>, Acc) -> [O|Acc]; - (_, Acc) -> Acc - end, [], Opts)), - io:format("~s~n", [[["-", O] || O <- Filtered]]), + Opts = init:get_plain_arguments(), + {Filtered, _} = lists:foldl(fun + (O, {Os, true}) -> {[O|Os], false}; + (O = "-D", {Os, _}) -> {[O|Os], true}; + (O = [\\$$-, \\$$D, _ | _], {Os, _}) -> {[O|Os], false}; + (O = "-I", {Os, _}) -> {[O|Os], true}; + (O = [\\$$-, \\$$I, _ | _], {Os, _}) -> {[O|Os], false}; + (O = "-pa", {Os, _}) -> {[O|Os], true}; + (_, Acc) -> Acc + end, {[], false}, Opts), + io:format("~s~n", [string:join(lists:reverse(Filtered), " ")]), halt(). endef @@ -51,4 +54,4 @@ dialyze: else dialyze: $(DIALYZER_PLT) endif - $(verbose) dialyzer --no_native `$(call erlang,$(call filter_opts.erl,$(ERLC_OPTS)))` $(DIALYZER_DIRS) $(DIALYZER_OPTS) + $(verbose) dialyzer --no_native `$(ERL) -eval "$(subst $(newline),,$(subst ",\",$(call filter_opts.erl)))" -extra $(ERLC_OPTS)` $(DIALYZER_DIRS) $(DIALYZER_OPTS) |