3 ms·
If you're okay with depending on Git, you can use `git rev-parse --parseopt`. https://git-scm.com/docs/git-rev-parse#_parseopt https://git-scm.com/docs/git-rev
by mbrock 5y ago
If you're okay with depending on Git, you can use `git rev-parse --parseopt`.
https://git-scm.com/docs/git-rev-parse#_parseopt https://git-scm.com/docs/git-rev-parse#_parseopt
> In --parseopt mode, git rev-parse helps massaging options to bring to shell scripts the same facilities C builtins have. It works as an option normalizer (e.g. splits single switches aggregate values), a bit like getopt(1) does.
> It takes on the standard input the specification of the options to parse and understand, and echoes on the standard output a string suitable for sh(1) eval to replace the arguments with normalized ones. In case of error, it outputs usage on the standard error stream, and exits with code 129.
- unixhero 5y agoThis is really brilliant and I have never heard of this method before. Noting it down thank you.