From 94ea3c7b968421bc43a2ea81ed17372ccb14c4e1 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 10 Sep 2019 17:26:35 +0200 Subject: [PATCH] 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 '='? ``` --- pdns/pdns_recursor.cc | 15 ++++++++++++++- pdns/receiver.cc | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 0b7a8f098b..78d569df05 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<