From: Pieter Lexis Date: Tue, 10 Sep 2019 15:26:35 +0000 (+0200) Subject: Improve commandline error reporting for non-opts X-Git-Tag: dnsdist-1.4.0-rc3~27^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94ea3c7b968421bc43a2ea81ed17372ccb14c4e1;p=pdns Improve commandline error reporting for non-opts Before: ``` pdns_server --launch=random --socket-dir=. foo Fatal: non-option on the command line, perhaps a '--setting=123' statement missed the '='? ``` After: ``` pdns_server --launch=random --socket-dir=. bar Sep 10 17:24:25 Unable to open /usr/local/etc/pdns.conf Fatal: non-options (bar) on the command line, perhaps a '--setting=123' statement missed the '='? pdns_server --launch=random --socket-dir=. bar foo Sep 10 17:24:25 Unable to open /usr/local/etc/pdns.conf Fatal: non-options (bar, foo) on the command line, perhaps a '--setting=123' statement missed the '='? ``` --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 0b7a8f098..78d569df0 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -4646,7 +4646,20 @@ int main(int argc, char **argv) cleanSlashes(configname); if(!::arg().getCommands().empty()) { - cerr<<"Fatal: non-option on the command line, perhaps a '--setting=123' statement missed the '='?"< 1) { + cerr<<"s"; + } + cerr<<" ("; + bool first = true; + for (auto const c : ::arg().getCommands()) { + if (!first) { + cerr<<", "; + } + first = false; + cerr<