logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 859ae48850d00021fb5b5e78851b0d9b6909877e
parent c8a2a927ac04b648c25b574efbe162fa6983ff8a
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 24 Jul 2025 22:17:13 +0200

configure.d/getopt_long.c: also test `optional_argument`

Diffstat:

Mconfigure.d/getopt_long.c7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure.d/getopt_long.c b/configure.d/getopt_long.c @@ -18,11 +18,12 @@ main(int argc, char *argv[]) static struct option opts[] = { {"help", no_argument, NULL, 'h'}, {"file", required_argument, NULL, 'f'}, + {"iso-8601", optional_argument, NULL, 'I'}, {0, 0, 0, 0} }; // clang-format on - for(int c = -1; (c = getopt_long(argc, argv, ":hf:", opts, &optidx)) != -1;) + for(int c = -1; (c = getopt_long(argc, argv, ":hf:I::", opts, &optidx)) != -1;) { switch(c) { @@ -33,6 +34,10 @@ main(int argc, char *argv[]) case 'f': file = optarg; break; + case 'I': + if(optarg) puts(optarg); + return 2; + break; default: abort(); }