[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Issue with Getopt-declare incorrect parameter specification

Nexos

3/20/2007 10:19:00 PM

Hi,

I'm having a weird problem with the "Getopt-declare" library. I wrote:

require 'rubygems'
require 'Getopt/Declare'

pattern = ".*"
args = Getopt::Declare.new(%q@

-p <regexp> some regexp; defaults to ".*" (explanation)
{
pattern = regexp
}
@)

When I run: << ruby script.rb -p '[a-c].*' >>

, I get the following error:

"Error: incorrect specification of '-p' parameter"

Has someone an explanation for this ?

Thanks in advance,
Frédéric

5 Answers

gga

3/21/2007 7:31:00 AM

0



It seems to work for me with latest 1.22, albeit you should use
$pattern or @pattern. Otherwise pattern is a local variable to the
block.


require 'rubygems'
require 'Getopt/Declare'

@pattern = ".*"
args = Getopt::Declare.new(%q%
-p <regexp> some regexp; defaults to ".*" (explanation)
{
@pattern = regexp
}
%)

puts "VERSION #{Getopt::Declare::VERSION}"
p args
puts "PATTERN #@pattern"


> try.rb -p hello
VERSION 1.22
-p => "hello"
Unused:
PATTERN .*

Nexos

3/21/2007 10:42:00 AM

0

On 21 mar, 08:30, "gga" <GGarram...@aol.com> wrote:
> It seems to work for me with latest 1.22, albeit you should use
> $pattern or @pattern. Otherwise pattern is a local variable to the
> block.
>
> require 'rubygems'
> require 'Getopt/Declare'
>
> @pattern = ".*"
> args = Getopt::Declare.new(%q%
> -p <regexp> some regexp; defaults to ".*" (explanation)
> {
> @pattern = regexp
> }
> %)
>
> puts "VERSION #{Getopt::Declare::VERSION}"
> p args
> puts "PATTERN #@pattern"
>
> > try.rb -p hello
>
> VERSION 1.22
> -p => "hello"
> Unused:
> PATTERN .*

Thanks for the issue on the variable scope, but the error message
appears when you use a more complex argument value than 'hello',
i.e.

try.rb -p hello works fine

but

try.rb -p '[a-c].*' gives the error message


gga

3/21/2007 4:09:00 PM

0

On 21 mar, 07:41, "Nexos" <frederic.dela...@gmail.com> wrote:
> On 21 mar, 08:30, "gga" <GGarram...@aol.com> wrote:
>
>
>
>
>
>
>
> > It seems to work for me with latest 1.22, albeit you should use
> > $pattern or @pattern. Otherwise pattern is a local variable to the
> > block.
>
> > require 'rubygems'
> > require 'Getopt/Declare'
>
> > @pattern = ".*"
> > args = Getopt::Declare.new(%q%
> > -p <regexp> some regexp; defaults to ".*" (explanation)
> > {
> > @pattern = regexp
> > }
> > %)
>
> > puts "VERSION #{Getopt::Declare::VERSION}"
> > p args
> > puts "PATTERN #@pattern"
>
> > > try.rb -p hello
>
> > VERSION 1.22
> > -p => "hello"
> > Unused:
> > PATTERN .*
>
> Thanks for the issue on the variable scope, but the error message
> appears when you use a more complex argument value than 'hello',
> i.e.
>
> try.rb -p hello works fine
>
> but
>
> try.rb -p '[a-c].*' gives the error message

Oh, yes. This is a bug I recently stumbled upon and has been fixed.

The problem is in Getopt/Declare.rb, around line 668. There's a:

code << '\b'

Just comment that out. I'll be making a new release with that fix
soon, but I am also adding a more complex Test::Unit test suite to
catch those sort of errors.

Nexos

3/21/2007 7:46:00 PM

0

On Mar 21, 5:08 pm, "gga" <GGarramuno@aol.com> wrote:
> On 21 mar, 07:41, "Nexos" <frederic.dela...@gmail.com> wrote:
>
>
>
> > On 21 mar, 08:30, "gga" <GGarram...@aol.com> wrote:
>
> > > It seems to work for me with latest 1.22, albeit you should use
> > > $pattern or @pattern. Otherwise pattern is a local variable to the
> > > block.
>
> > > require 'rubygems'
> > > require 'Getopt/Declare'
>
> > > @pattern = ".*"
> > > args =Getopt::Declare.new(%q%
> > > -p <regexp> some regexp; defaults to ".*" (explanation)
> > > {
> > > @pattern = regexp
> > > }
> > > %)
>
> > > puts "VERSION #{Getopt::Declare::VERSION}"
> > > p args
> > > puts "PATTERN #@pattern"
>
> > > > try.rb -p hello
>
> > > VERSION 1.22
> > > -p => "hello"
> > > Unused:
> > > PATTERN .*
>
> > Thanks for the issue on the variable scope, but the error message
> > appears when you use a more complex argument value than 'hello',
> > i.e.
>
> > try.rb -p hello works fine
>
> > but
>
> > try.rb -p '[a-c].*' gives the error message
>
> Oh, yes. This is a bug I recently stumbled upon and has been fixed.
>
> The problem is inGetopt/Declare.rb, around line 668. There's a:
>
> code << '\b'
>
> Just comment that out. I'll be making a new release with that fix
> soon, but I am also adding a more complex Test::Unit test suite to
> catch those sort of errors.

OK.
Just tried it and it worked fine.

Thanks for explanation!

Regards,

Frédéric Delanoy

Dave Heil

3/17/2011 4:44:00 PM

0

On 3/17/2011 05 42, Ray Fischer wrote:
> David Hartung<david@hotmai*l.com> wrote:
>> On 03/15/2011 11:11 AM, Lee Curtis wrote:
>>> David Hartung wrote:
>>>
>>>> On 03/14/2011 03:11 PM, Lee Curtis wrote:
>>>>> David Hartung wrote:
>>>>>
>>>>>> On 03/13/2011 08:05 PM, Lee Curtis wrote:
>>>>>>> Criminal Drivers Murder 35,000 Americans a Year wrote:
>>>>>>>
>>>>>>>> On Mar 13, 7:02 am, David Hartung<david@hotmai*l.com> wrote:
>>>>>>>>>>
>>>>>>>>> Under what authority does the DOJ dictate hiring and testing
>>>>>>>>> standards to local authorities?-
>>>>>>>>
>>>>>>>>
>>>>>>>> I thought that was strange too. This country has really
>>>>>>>> changed in the last 230 years. America was supposed to have a
>>>>>>>> limited central govt but it's gone just the other way and the
>>>>>>>> feds now control everything and the states are nothing.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> The founding fathers tried having "limited government"
>>>>>>> and it didn't work.
>>>>>>
>>>>>> How did you reach this astounding conclusion?
>>>>>
>>>>>
>>>>>
>>>>> Read up on our first few presidents. Shay's Rebellion,
>>>>> the Whisky Rebellion, states refusing to pay for the war
>>>>> debts, they all had headaches with limited government. No
>>>>> wonder Alexander Hamilton wanted the US to become a monarchy,
>>>>> just so the federal government would have some authority.
>>>>
>>>> You post this crap, and then you have the nerve to question the
>>>> intellect of others?
>>>
>>>
>>> You run away like a scared rabbit everytime your
>>> own proof proves you wrong and you dare to question the
>>> intellect of others?
>>
>> In you very subjective, partisan opinion perhaps.
>
> 92% on the irony meter.

You just hit 100% on the irony meter, Wrong Ray.