enh: osh-encrypt-rsync: catch warnings emitted by GetOptions

This commit is contained in:
Stéphane Lesimple 2022-01-21 13:26:24 +00:00 committed by Stéphane Lesimple
parent c38c9c09f2
commit bd13e5a476

View file

@ -549,6 +549,9 @@ EOF
sub main {
_log "Starting...";
{
my $optwarn = 'Unknown error';
local $SIG{'__WARN__'} = sub { $optwarn = shift; };
if (
!GetOptions(
"dry-run" => \$dryRun,
@ -563,10 +566,11 @@ sub main {
)
)
{
_err "Error while parsing command-line options";
_err "Error while parsing command-line options: $optwarn";
print_usage();
return 1;
}
}
if ($help) {
print_usage();