www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11764] New: [REG2.065a]std.getopt broken

reply d-bugmail puremagic.com writes:
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



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: -------
Dec 18 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11764


monarchdodra gmail.com changed:

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



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: -------
Dec 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Dec 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11764


Andrei Alexandrescu <andrei erdani.com> changed:

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



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: -------
Dec 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11764




10:23:56 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". 
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: -------
Dec 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11764




PST ---
Oh I see. Nice!

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11764




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: -------
Dec 18 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11764




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


Fix issue 11764

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 18 2013
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Dec 18 2013