On Fri Apr 08 19:39:49 2016, madcap.russo...@gmail.com wrote:
> From IRC:
> 9:22 PM <MadcapJake> if I pass a : at the beginning of a string
> argument to MAIN, it fails to match any signatures and triggers the
> Usage message
> 9:25 PM <ZoffixWin> MadcapJake, can't reproduce. What's the sig for
> MAIN you're using and what's the way you're calling the script with?
> 9:25 PM <MadcapJake> ./bin/rabble -e -d ": addone 1 + ; 1 addone ."
> 9:26 PM <ZoffixWin> MadcapJake, but the usage message tells you to use
> -d="..." doesn't it? You're missing the equals sign
> 9:26 PM <MadcapJake> no, those are Bools
>  9:27 PM <MadcapJake> ~/github/rabble/bin/rabble --expression|-e [--
> debug|-d] <expr>
> 9:27 PM <MadcapJake> ~/github/rabble/bin/rabble [--debug|-d] <file>
> 9:28 PM <ZoffixWin> MadcapJake, confirmed on my box. You should
> rakudobug this:   perl6 -e 'sub MAIN ($x) {}' ": 42"   <-- triggers
> usage... perl6 -e 'sub MAIN ($x) {}' "42" <-- no usage
> 9:28 PM <MadcapJake> :(Str $expr, Bool :expression(:$e)!, Bool
> :debug(:$d)) is the signature I'm trying to match
> 9:29 PM <ZoffixWin> The bug seems to exist with a single positional as
> well. A ":" as the first char in the positional breaks something
> 9:33 PM <ZoffixWin> MadcapJake, are you rakudobugging it? I found this
> works: to set $y to 45: perl6 -e 'sub MAIN ($x, :$y) { say $y }'
> ":y=45" 42
> 9:34 PM <ZoffixWin> In addition it's also impossible to pass "-y=45"
> to a positional argument, because it gets interpreted as a named arg,
> it seems
> 9:35 PM <teatime> ZoffixWin: even if you do -- first ?
> 9:35 PM <ZoffixWin> teatime, was about to say.... the -- is the way.
> 9:35 PM <ZoffixWin> This is more about the shell than Perl 6, but :y
> should still be parsed as normal string and not a named arg IMO
> 9:36 PM <ZoffixWin> perl6 -e 'sub MAIN ($x) { say $x }' -- ":y=45"
> works fine
> 9:36 PM <ZoffixWin> Unless there are some shells where : instead of -
> on args is used that I'm unaware of.

S19 specifies 

  Options must begin with one of the following symbols: --, -, or :. 

So this is not up to the shell, but the interpreter.

Of course, that doesn't change that there's something weird. Consider the 
following examples:

$ ./perl6-m --version
This is Rakudo version 2016.03-106-gd847011 built on MoarVM version 
2016.03-104-g10d3971
implementing Perl 6.c.
$ ./perl6-m "--version"
This is Rakudo version 2016.03-106-gd847011 built on MoarVM version 
2016.03-104-g10d3971
implementing Perl 6.c.
$ ./perl6-m -e'multi MAIN($a) { say "pos" }; multi MAIN(:$a) { say "named" }' 
":a"
named
$ ./perl6-m -e'multi MAIN($a) { say "pos" }; multi MAIN(:$a) { say "named" }' 
-- ":a"
named
$ ./perl6-m -e'multi MAIN($a) { say "pos" }; multi MAIN(:$a) { say "named" }' 
-- "--a"
named
$ ./perl6-m -e'multi MAIN($a) { say "pos" }; multi MAIN(:$a) { say "named" }' 
"--a"
Illegal option --a
[rest of < perl6 --help > here]

The last case is probably the most interesting one... :)

In any case, what actually seems to be wrong is that the interpreter can't 
distinguish between quoted arguments that look like switches and non-quoted 
switches, and -- as "only arguments from here on" doesn't seem to work 
completely reliably either.

Reply via email to