Skip to content

Fix command-line parsing on Alpine Linux (#905) #1090

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

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

Conversation

felixbuenemann
Copy link

@felixbuenemann felixbuenemann commented Jul 14, 2025

Add POSIX mode prefix (+) to root option string to ensure consistent getopt behavior between glibc and musl libc. This fixes an issue where subcommand options like pg_autoctl create postgres --help were not being recognized on Alpine Linux due to musl's different handling of unknown options when POSIXLY_CORRECT=1 is set.

Fixes #905

Tested the fix by compiling against both the official postgres:17 (Debian Bookworm / glibc) and postgres:17-alpine (Alpine 3.22 / musl) Docker containers and macOS 15.5 Homebrew postgresql@17.

Without this fix pg_autoctl is unusable on Alpine Linux and other musl libc based systems.

Add POSIX mode prefix (+) to root option string to ensure consistent
getopt behavior between glibc and musl libc. This fixes an issue where
subcommand options like 'pg_autoctl create postgres --help' were not
being recognized on Alpine Linux due to musl's different handling of
unknown options when POSIXLY_CORRECT=1 is set.
@felixbuenemann
Copy link
Author

@DimCitus Looks like you tried to fix this earlier. I haven't tried compiling this fix on macOS yet…

@felixbuenemann
Copy link
Author

OK, I verified the fix does not break option parsing on macOS 15.5 / Homebrew.

@felixbuenemann
Copy link
Author

I noticed there is PR #1084, which is probably a more comprehensive / cleaner fix since it also removes the POSIXLY_CORRECT environment variable hacks in the option parser code.

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.

pg_autoctl: unrecognized option on Alpine Linux
1 participant