From 5930775626a34beebd283a5c0558f299eef59686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Wed, 1 Sep 2021 16:00:28 +0000 Subject: [PATCH] enh: better error message when unknown option is used --- bin/shell/osh.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/shell/osh.pl b/bin/shell/osh.pl index 3d25fea..5534429 100755 --- a/bin/shell/osh.pl +++ b/bin/shell/osh.pl @@ -575,6 +575,15 @@ my $ip = undef; # if: avoid loading Net::IP and BigInt if there's no host specified if ($host) { + + # probably this "host" is in fact an option, but we didn't parse it because it's an unknown one, + # so we call the long_help() for the user, before exiting + if ($host =~ m{^--}) { + long_help(); + main_exit OVH::Bastion::EXIT_GETOPTS_FAILED, 'getopts_failed', "Couldn't parse option '$host'"; + } + + # otherwise, resolve the host $fnret = OVH::Bastion::get_ip(host => $host); } if (!$fnret) {