Skip to content

Conversation

yedayak
Copy link
Collaborator

@yedayak yedayak commented Sep 28, 2025

The usage output on macos is in bsd style, not gnu style
Cherry picked from #1339

The usage output on macos is in bsd style, not gnu style
Also other bsd types OSs
Copy link
Owner

@scop scop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Pre-approved with requested changes.)

Comment on lines +53 to +57
if [[ $OSTYPE == *@(darwin|bsd)* ]]; then
_comp_compgen_usage
else
_comp_compgen_help
fi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, the preferred pattern for cases like these is

Suggested change
if [[ $OSTYPE == *@(darwin|bsd)* ]]; then
_comp_compgen_usage
else
_comp_compgen_help
fi
_comp_compgen_help || _comp_compgen_usage

This frees us from hardwiring "known" OS dependencies, as well as helps with cases for which detection isn't that feasible, such as Alpine systems where a command might be a GNU one supporting long options (_comp_compgen_help applies), or a busybox one that supports only short ones (_comp_compgen_usage applies).


if [[ $cur == -* ]]; then
_comp_compgen_help
if [[ $OSTYPE == *@(darwin|bsd)* ]]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

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.

3 participants