Thread overview
[Issue 11764] New: [REG2.065a]std.getopt broken
Dec 18, 2013
SHOO
Dec 18, 2013
Andrej Mitrovic
Dec 18, 2013
Andrej Mitrovic
Dec 18, 2013
Andrej Mitrovic
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764

           Summary: [REG2.065a]std.getopt broken
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: zan77137@nifty.com


--- Comment #0 from SHOO <zan77137@nifty.com> 2013-12-18 07:16:21 PST ---
This code doesn't work (git HEAD):

import std.getopt;
import std.stdio;

void main()
{
    auto args = ["main", "-test"];
    bool opt;
    args.getopt(config.passThrough, "opt", &opt);
    writeln(args);
    assert(args == ["main", "-test"]);
}
----

$ dmd -run main
["main", "-t", "est"]
core.exception.AssertError@main(10): Assertion failure

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764


monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com


--- Comment #1 from monarchdodra@gmail.com 2013-12-18 08:54:06 PST ---
Introduced by: https://github.com/D-Programming-Language/phobos/pull/1779

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-12-18 09:38:18 PST ---
I guess getopt should check whether the option exists before it tries to separate "-abc" to -a=bc?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com


--- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> 2013-12-18 09:42:09 PST ---
This is intentional because arguably the use was incorrectly accepted. The commonly used convention is to either use short (single-letter) options with single dash, or long options (multi-letter) with double dashes.

The use '-test' is currently interpreted as "pass argument est to the single-letter option -t".

That said, a regression is what it is so perhaps we need to continue supporting the old mistake. I'll look into it. Please advise.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-12-18 10:23:56 PST ---
(In reply to comment #3)
> This is intentional because arguably the use was incorrectly accepted. The commonly used convention is to either use short (single-letter) options with single dash, or long options (multi-letter) with double dashes.
> 
> The use '-test' is currently interpreted as "pass argument est to the single-letter option -t".

I think the OPs point however is that the passThrough option should let *you* handle any unsupported syntax like single-dash long options *after* getopt is done, hence why it should not split up "-test" (if there's no -t option then it should arguably not try to split up -test).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764



--- Comment #5 from Andrei Alexandrescu <andrei@erdani.com> 2013-12-18 11:24:37 PST ---
Oh I see. Nice!

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764



--- Comment #6 from Andrei Alexandrescu <andrei@erdani.com> 2013-12-18 12:30:21 PST ---
https://github.com/D-Programming-Language/phobos/pull/1783

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764



--- Comment #7 from github-bugzilla@puremagic.com 2013-12-18 13:46:13 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/4900690b77ebcd0ae3248119f706e0efac7dcfdc Fix issue 11764

https://github.com/D-Programming-Language/phobos/commit/ac83fa77067e50142723d480614ec72d6c40a459 Merge pull request #1783 from andralex/getopt

Fix issue 11764

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11764


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------