Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to getopt_long() to fix linking against musl #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

apritzel
Copy link
Owner

We don't really need long options, but using getopt_long(), which is a GNU extension, relaxes the strict requirements that the strict POSIX compliant musl implementation of getopt() has. This behaviour stops parsing when it finds the first non-option argument, which is our action verb. So any parameter afterwards (like -v) is ignored.

The glibc implementation of getopt() and all getopt_long() implementations shuffle argv and put option arguments first, so work as expected.

This fixes operation on musl based systems, or when compiling a static binary with musl.

We don't really need long options, but using getopt_long(), which is a GNU
extension, relaxes the strict requirements that the strict POSIX
compliant musl implementation of getopt() has. This behaviour stops
parsing when it finds the first non-option argument, which is our action
verb. So any parameter afterwards (like -v) is ignored.

The glibc implementation of getopt() and all getopt_long() implementations
shuffle argv and put option arguments first, so work as expected.

This fixes operation on musl based systems, or when compiling a static
binary with musl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant