NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/59828: getopt(3) GNU extension wrong behavior



The following reply was made to PR lib/59828; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: lib/59828: getopt(3) GNU extension wrong behavior
Date: Wed, 10 Dec 2025 09:18:22 -0000 (UTC)

 rootnode+netbsd%wollwage.com@localhost writes:
 
 >$ date -Idate
 >2025-12-04
 >$ date -I date
 >date: illegal time format
 >usage: date [-jnRu] [-I[date|hours|minutes|seconds]] [-f input_fmt]
 >            [-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]
 >            [[[[[[cc]yy]mm]dd]HH]MM[.SS] | new_date] [+output_fmt]
 
 
 NetBSD date doesn't have an -I option.
 
 The coreutils package from pkgsrc contains a date command, but
 which works the same as on Linux:
 
 NetBSD-10, coreutils-9.6nb1:
 
 % /usr/pkg/gnu/bin/date -I date
 date: invalid date date
 
 % /usr/pkg/gnu/bin/date -"I date"
 date: invalid argument  date for --iso-8601
 Valid arguments are:
   - hours
   - minutes
   - date
   - seconds
   - ns
 Try '/usr/pkg/gnu/bin/date --help' for more information.
 
 % /usr/pkg/gnu/bin/date -Idate
 2025-12-10
 
 Debian trixie, coreutils 9.7-3:
 
 $ date -I date
 date: invalid date 'date'
 
 $ date -"I date"
 date: invalid argument ' date' for '--iso-8601'
 Valid arguments are:
   - 'hours'
   - 'minutes'
   - 'date'
   - 'seconds'
   - 'ns'
 Try 'date --help' for more information.
 
 $ date -Idate
 2025-12-10
 
 
 I don't think your interpretation of the manual page is correct,
 but without an example for "x::" maybe misleading.
 
 "If an individual character is followed by two colons, then the
 option argument is optional; optarg is set to the rest of the
 current argv word, or NULL if there were no more characters in the
 current word."
 
 So, the option argument is "the rest of the current argv word" or "NULL".
 It is never "the following word if that doesn't start with a dash".
 
 
 No idea why FreeBSD calls it a "GNU extension" while NetBSD calls it
 a "NetBSD extension" or who actually created it...
 
 


Home | Main Index | Thread Index | Old Index