Fix issue 5762

Also fixed a related issue -Dname=value. Previously it was interpreted as a "flag -Dname gets value" but long names with one single dash should not work. So this diff interprets it as 'D name=value'.