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

--- Comment #9 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 208591
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208591&action=edit
Bug 43557: (follow-up) Accept legacy single-dash long options with a
deprecation warning

Scripts converted to Koha::Script->describe_options used to be parsed by
plain Getopt::Long, which also accepted a long option with a single dash
(-days 5). Several of them documented that form (holds_reminder.pl lists
-days, -lettercode, -date, -library and -holidays), so existing cron
lines use it. Getopt::Long::Descriptive parses with bundling, and -days
is then read as the flags -d -a -y -s: the script prints its usage and
exits 1, and the cron job silently stops running.

Rewrite such an argument as the standard --days, and print a deprecation
warning to STDERR (cron mails it to the administrator) so existing
command lines keep working while they are migrated. An argument is only
rewritten if it is a single dash and at least two characters, and names a
declared long option or the unique prefix of one (as plain Getopt::Long
allowed), and it is not a bundle of declared one-character flags (-vc is
still -v -c). The values given to options, and anything after --, are
left alone. -help and -man work too. This is a compatibility shim to be
removed in a future release; --long remains the documented form.

Test plan:
1. Apply the patch
2. prove t/Koha/Script.t
3. Run a converted script with a legacy option, for example
   misc/cronjobs/holds/holds_reminder.pl -days 3 (with the patch of
   bug 43553): it runs, and prints
   WARNING: -days is deprecated, use --days instead (...)
4. Run it with --days 3: it runs and prints no warning

Co-Authored-By: Claude Sonnet 5.5 <[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