IEEE Std 1003.1-2008, Section 1.4, Utility Description Defaults says
that when the options section is listed as "None", utility shall recognize "--" as a first argument to be discarded. This implementation is largely based on OpenBSD implementation but we do slightly differently: a) We skip argv[0] as the first step; b) We test whether the next argument is "--" and ignore it. With this change one will get: %printf usage: printf format [arguments ...] %printf -v -v%printf -- -v -v% %printf -- usage: printf format [arguments ...] Which matches the behavior observed on a Debian system but different from the Illumos change.
This commit is contained in:
parent
6715165066
commit
02a4a3f56c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216423
@ -102,7 +102,7 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
int ch, chopped, end, rval;
|
int chopped, end, rval;
|
||||||
char *format, *fmt, *start;
|
char *format, *fmt, *start;
|
||||||
|
|
||||||
#ifndef SHELL
|
#ifndef SHELL
|
||||||
@ -111,15 +111,15 @@ main(int argc, char *argv[])
|
|||||||
#ifdef SHELL
|
#ifdef SHELL
|
||||||
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
|
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
|
||||||
#endif
|
#endif
|
||||||
while ((ch = getopt(argc, argv, "")) != -1)
|
/* Skip argv[0] which is the process name */
|
||||||
switch (ch) {
|
argv++;
|
||||||
case '?':
|
argc--;
|
||||||
default:
|
|
||||||
usage();
|
/* Need to accept/ignore "--" option. */
|
||||||
/* NOTREACHED */
|
if (argc >= 1 && strcmp(*argv, "--") == 0) {
|
||||||
}
|
argc--;
|
||||||
argc -= optind;
|
argv++;
|
||||||
argv += optind;
|
}
|
||||||
|
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
usage();
|
usage();
|
||||||
|
Loading…
Reference in New Issue
Block a user