getopt: fix optional argument processing