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

Consider merging GNU and POSIX templates and use getopt/getopts based on availability #4

Open
wwerner opened this issue Oct 28, 2018 · 1 comment
Assignees
Labels

Comments

@wwerner
Copy link
Owner

wwerner commented Oct 28, 2018

Using this pattern, we can detect whether GNU getopt is available and use it:

getopt -T > /dev/null
if [ $? -eq 4 ]; then
    # GNU enhanced getopt is available
    set -- `getopt --long help,output:,version --options ho:v -- "$@"`
else
    # Original getopt is available
    set -- `getopt ho:v "$@"`
fi
@wwerner
Copy link
Owner Author

wwerner commented Nov 26, 2018

As an alternative, we could use the getops.sh script providing a posix compliant parser for long options: https://gist.github.com/wwerner/31758b8083746eb285e7eb62b55e532e

@wwerner wwerner self-assigned this Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant