Closed N-R-K closed 1 year ago
https://man.freebsd.org/cgi/man.cgi?getopt(3)
The getopt() function was once specified to return EOF instead of -1.
This was changed by IEEE Std 1003.2-1992 ("POSIX.2") to decouple getopt()
from <stdio.h>.
Probably, getopt_long()
inherited the old POSIX getopt()
behavior, and maybe scrot was initially developed with a pre-1992 version of POSIX in mind.
Thanks, I've changed the commit message.
Noticed these while I was trying to add
--delay-select
for #221options: test against correct return value
getopt_long manpage says:
| If all command-line options have been parsed, then getopt() returns -1.
it doesn't say anything about returning EOF. but since EOF is typically defined as -1 it ended up working by accident.
options: remove unused variable
getopt_long accepts NULL as longindex argument, so no need to pass a dummy variable.