-=| Dominic Hargreaves, 07.02.2012 19:57:30 +0000 |=-
> On Mon, Feb 06, 2012 at 05:45:21PM -0500, Bdale Garbee wrote:
> > > or (ideally) to replace their use with more modern equivalents.
> >
> > I don't know enough about perl to replace the use of newgetopt.pl by
> > server-src/amstatus.pl in amanda with the recommended Getopt::Long. I
> > would be happy to accept a patch that implements the change, however, if
> > someone who knows more about perl is willing to create such a patch for
> > me?
>
> Okay; CCing to debian-perl in case there is any interest there.
Thanks!
The patch is surprisingly simple, thanks to the following passage in
Getopt::Long(3pm):
Legacy
The earliest development of "newgetopt.pl" started in 1990, with
Perl version 4. As a result, its development, and the development
of Getopt::Long, has gone through several stages. Since backward
compatibility has always been extremely important, the current
version of Getopt::Long still supports a lot of constructs that
nowadays are no longer necessary or otherwise unwanted. This
section describes briefly some of these 'features'.
Default destinations
When no destination is specified for an option, GetOptions will
store the resultant value in a global variable named "opt_"XXX,
where XXX is the primary name of this option. When a progam
executes under "use strict" (recommended), these variables must
be pre-declared with our() or "use vars".
our $opt_length = 0;
GetOptions ('length=i'); # will store in $opt_length
Since 'use strict' is not used, the attached patch should be
sufficient. The only additional change is in checking the result of
GetOptions, which is documented to either be true or false, not 1 and
0.
Cheers!
diff --git a/server-src/amstatus.pl b/server-src/amstatus.pl
index be2b8fe..775d188 100644
--- a/server-src/amstatus.pl
+++ b/server-src/amstatus.pl
@@ -6,13 +6,13 @@ eval '(exit $?0)' && eval 'exec @PERL@ -S $0 ${1+"$@"}'
& eval 'exec @PERL@ -S $0 $argv:q'
if 0;
-require "newgetopt.pl";
use warnings;
use lib '@amperldir@';
use Time::Local;
use Text::ParseWords;
use Amanda::Util;
use Amanda::Process;
+use Getopt::Long;
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'PATH'};
$ENV{'PATH'} = "/bin:/usr/bin:/usr/sbin:/sbin"; # force known path
@@ -33,7 +33,7 @@ $STATUS_MISSING = 8;
$STATUS_TAPE = 16;
$exit_status = 0;
-$result = &NGetOpt ( "summary",
+$result = GetOptions ( "summary",
"stats|statistics",
"dumping|d",
"waitdumping|wdumping",
@@ -49,7 +49,7 @@ $result = &NGetOpt ( "summary",
"file:s",
"locale-independent-date-format",
);
-if($result !=1 ) {
+if( !$result ) {
&usage();
}
Attachment:
signature.asc
Description: Digital signature