https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43546

--- Comment #22 from Andrew Fuerste-Henry <[email protected]> ---
Created attachment 207921
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207921&action=edit
Bug 43546: (follow-up) Exit with status 1 on command-line errors

Getopt::Long::Descriptive reports errors with die, and an uncaught die
exits with the value of $! if it is not 0. So a script converted to
Koha::Script->describe_options exits with an unpredictable status on an
unknown option, a missing required option or a $usage->die call: 11
for cleanup_database.pl in KTD, 2 after a failed open... The scripts
exited with status 1 before, with pod2usage(1) or usage(1).

describe_options now:
- returns a Koha::Script::Usage object, whose die makes the script exit
  with status 1,
- also exits with status 1 when Getopt::Long::Descriptive itself fails
  (unknown option, missing required option).

The exceptions can still be caught with eval or throws_ok.

Test plan:
1. prove t/Koha/Script.t
2. misc/cronjobs/cart_to_shelf.pl --bogus; echo $?
   => 1
3. misc/cronjobs/cart_to_shelf.pl; echo $?
   => 1 (--hours is required)
4. misc/cronjobs/cart_to_shelf.pl --help; echo $?
   => 0

Signed-off-by: Andrew Fuerste Henry <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to