Fix issue 5762
Merge pull request #1779 from andralex/getopt

Fix issue 5762