Skip Menu |

This queue is for tickets about the AFS-Command CPAN distribution.

Report information
The Basics
Id: 100495
Status: new
Priority: 0/
Queue: AFS-Command

People
Owner: Nobody in particular
Requestors: sjq-perl [...] jadevine.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Fails to parse arguments for "fs setcachesize"
When I try to use the setcachesize method in AFS::Command::FS it fails to parse the argument list: unable to parse fs help for setcachesize Unrecognized string: '[-blocks <size in 1K byte blocks (0 => reset)>] [-reset] [-help] The help text on my machine with 1.6.10 installed gives: % fs help setcachesize fs setcachesize: set cache size aliases: cachesize Usage: fs setcachesize [-blocks <size in 1K byte blocks (0 => reset)>] [-reset] [-help] Where: -reset reset size back to boot value
Further to this, the same problem affects the "fs precache" command: /usr/bin/fs precache [-blocks <size in 1K byte blocks (0 => disable)>] [-help] To check for other problems with the help text parsing, I've now been through all of the operations for fs, bos, vos and pts commands and discovered there's a further different problem with "fs uuid": /usr/bin/fs uuid -generate [-help] I'll take a look at the _arguments subroutine in AFS::Command::Base and see if I can come up with a suitable patch. Stephen On Fri Nov 21 12:08:16 2014, SJQUINNEY wrote: Show quoted text
> When I try to use the setcachesize method in AFS::Command::FS it fails > to parse the argument list: > > unable to parse fs help for setcachesize > Unrecognized string: '[-blocks <size in 1K byte blocks (0 => reset)>] > [-reset] [-help] > > The help text on my machine with 1.6.10 installed gives: > > % fs help setcachesize > fs setcachesize: set cache size > aliases: cachesize > Usage: fs setcachesize [-blocks <size in 1K byte blocks (0 => reset)>] > [-reset] [-help] > Where: -reset reset size back to boot value
Attached is a patch which I think fixes the problems in the help text parsing. I've tweaked the way the optional arguments are parsed to allow the '>' character inside the [], this fixes "fs setcachesize" and "fs precache". I also dropped the unnecessary '?' after the \w+ used in each regexp for the option name, this made it excessively non-greedy in some cases. This fixes the "fs uuid" problem. I've checked through all current commands and operations and my changes seem to work correctly but clearly this code will always be a little fragile since it relies on the openafs commands generating well-formed help text. Stephen On Mon Nov 24 07:00:15 2014, SJQUINNEY wrote: Show quoted text
> Further to this, the same problem affects the "fs precache" command: > > /usr/bin/fs precache [-blocks <size in 1K byte blocks (0 => disable)>] > [-help] > > To check for other problems with the help text parsing, I've now been > through all of the operations for fs, bos, vos and pts commands and > discovered there's a further different problem with "fs uuid": > > /usr/bin/fs uuid -generate [-help] > > I'll take a look at the _arguments subroutine in AFS::Command::Base > and see if I can come up with a suitable patch. > > > Stephen > > > On Fri Nov 21 12:08:16 2014, SJQUINNEY wrote:
> > When I try to use the setcachesize method in AFS::Command::FS it > > fails > > to parse the argument list: > > > > unable to parse fs help for setcachesize > > Unrecognized string: '[-blocks <size in 1K byte blocks (0 => reset)>] > > [-reset] [-help] > > > > The help text on my machine with 1.6.10 installed gives: > > > > % fs help setcachesize > > fs setcachesize: set cache size > > aliases: cachesize > > Usage: fs setcachesize [-blocks <size in 1K byte blocks (0 => > > reset)>] > > [-reset] [-help] > > Where: -reset reset size back to boot value
Subject: AFS-Command-arguments.patch
diff -ruNpwb AFS-Command-1.99.orig/lib/AFS/Command/Base.pm AFS-Command-1.99/lib/AFS/Command/Base.pm --- AFS-Command-1.99.orig/lib/AFS/Command/Base.pm 2010-10-15 17:38:39.000000000 +0100 +++ AFS-Command-1.99/lib/AFS/Command/Base.pm 2014-11-24 12:31:18.000000000 +0000 @@ -254,18 +254,18 @@ sub _arguments { next unless s/^Usage:.*\s+$operation\s+//; while ( $_ ) { - if ( s/^\[\s*-(\w+?)\s*\]\s*// ) { + if ( s/^\[\s*-(\w+)\s*\]\s*// ) { $arguments->{optional}->{$1} = 0 unless $1 eq 'help'; # Yeah, skip it... - } elsif ( s/^\[\s*-(\w+?)\s+<[^>]*?>\+\s*]\s*// ) { + } elsif ( s/^\[\s*-(\w+)\s+<.*?>\+\s*]\s*// ) { $arguments->{optional}->{$1} = []; - } elsif ( s/^\[\s*-(\w+?)\s+<[^>]*?>\s*]\s*// ) { + } elsif ( s/^\[\s*-(\w+)\s+<.*?>\s*]\s*// ) { $arguments->{optional}->{$1} = 1; - } elsif ( s/^\s*-(\w+?)\s+<[^>]*?>\+\s*// ) { + } elsif ( s/^\s*-(\w+)\s+<[^>]*?>\+\s*// ) { $arguments->{required}->{$1} = []; - } elsif ( s/^\s*-(\w+?)\s+<[^>]*?>\s*// ) { + } elsif ( s/^\s*-(\w+)\s+<[^>]*?>\s*// ) { $arguments->{required}->{$1} = 1; - } elsif ( s/^\s*-(\w+?)\s*// ) { + } elsif ( s/^\s*-(\w+)\s*// ) { $arguments->{required}->{$1} = 0; } else { $self->_Carp("Unable to parse @command help for $operation\n" .