Opened 7 weeks ago

Closed 5 weeks ago

Last modified 4 weeks ago

#16866 closed enhancement (fixed)

Remove getopt

Reported by: michael2402 Owned by: michael2402
Priority: normal Milestone: 18.11
Component: Core Version:
Keywords: hack-weekend-2018-10 Cc:


Drop the gnu.getopt package

This is a really old C library and we would clean up our code a lot by using our own parser. This would also allow us to add common options (e.g. logging level, ...) to a common place.

Attachments (2)

remove-getopt.patch (105.8 KB) - added by michael2402 7 weeks ago.
remove-getopt.2.patch (120.5 KB) - added by michael2402 7 weeks ago.
... missed the test file

Download all attachments as: .zip

Change History (12)

comment:1 Changed 7 weeks ago by michael2402

Owner: changed from team to michael2402

comment:2 Changed 7 weeks ago by michael2402

While doing this I would like to drop some posix stuff that probably nobody uses (and that might be more confusing than useful). E.g.:

josm -W foo is the same as josm --foo (we did not activate this)

There are some other tweaks that are only activated if the system property gnu.posixly_correct is set (ignoring -- after short option, ...) that I will drop. An error message (e.g. missing argument) is displayed instead.

We will allow arguments to be specified before options.
So the format would be like this:

josm -o --option argument1 --with-arg=test --with-arg test -- argument2 argument3

-- is optional to mark all following arguments as non-properties to allow them to start with a -- (good for scripting)

I don't think we will break any scripts using this because only few people are aware of the tweaks you could have done using posix getopts and fewer people used them.

comment:3 Changed 7 weeks ago by Don-vip

I didn't even know about this strange syntax. No objections to drop it.

Changed 7 weeks ago by michael2402

Attachment: remove-getopt.patch added

comment:4 Changed 7 weeks ago by michael2402

The patch is complete, just needs testing (I have not really played around with the program arguments and tested the two CLI applications)

TODO for sometime during this week.

Changed 7 weeks ago by michael2402

Attachment: remove-getopt.2.patch added

... missed the test file

comment:5 Changed 6 weeks ago by Don-vip

Milestone: 18.1018.11

comment:6 Changed 5 weeks ago by michael2402

In 14415/josm:

See #16866: Drop getopt, use own option parser.

comment:7 Changed 5 weeks ago by michael2402

Resolution: fixed
Status: newclosed

Getopt is removed, let me know if there are any issues with the new parsing mechanism. I tested a few variants and added a full unit test for the parser logic, but there might be some cases that I missed.

comment:8 Changed 5 weeks ago by michael2402

In 14416/josm:

See #16866: Fix errorprone warning.

comment:9 Changed 5 weeks ago by Don-vip

In 14417/josm:

see #16866 - drop/update remaining files

comment:10 Changed 4 weeks ago by Don-vip

In 14419/josm:

see #16866 : fix PMD warnings

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain michael2402.
as The resolution will be set.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.