-
Notifications
You must be signed in to change notification settings - Fork 402
fix(patch, truncate): Get help correctly on macos #1442
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
base: main
Are you sure you want to change the base?
Conversation
d759b6e
to
572afb8
Compare
The usage output on macos is in bsd style, not gnu style Also other bsd types OSs
572afb8
to
ad62378
Compare
There was a problem hiding this 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.)
if [[ $OSTYPE == *@(darwin|bsd)* ]]; then | ||
_comp_compgen_usage | ||
else | ||
_comp_compgen_help | ||
fi |
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
The usage output on macos is in bsd style, not gnu style
Cherry picked from #1339