]> git.ipfire.org Git - thirdparty/systemd.git/commit
musl: introduce wrappers for getopt() and getopt_long()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 30 Nov 2025 02:10:02 +0000 (11:10 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 Dec 2025 10:01:09 +0000 (11:01 +0100)
commit53f5aa3fd2423b9dac91049a5d4e8df5666cf4b3
tree8ddeccdda34e2968dc3d6a89294670637f20e264
parent26b2085d54ebbfca8637362eafcb4a8e3faf832f
musl: introduce wrappers for getopt() and getopt_long()

musl's getopt_long() behaves something different in handling optional arguments:
```
$ journalctl _PID=1 _COMM=systemd --since 19:19:01 -n all --follow
Failed to add match 'all': Invalid argument
```
This introduces getopt_long_fix() that reorders the passed arguments to make
getopt_long() provided by musl works as what we expect.

Also, musl's getopt() always behaves POSIXLY_CORRECT mode, and stops parsing
arguments when a non-option string found. Let's always use getopt_long().
src/include/musl/getopt.h [new file with mode: 0644]
src/include/musl/unistd.h [new file with mode: 0644]
src/libc/musl/getopt.c [new file with mode: 0644]
src/libc/musl/meson.build
src/test/meson.build
src/test/test-getopt.c [new file with mode: 0644]