Hacker News new | ask | show | jobs
by databasher 2256 days ago
Like @bxparks, I have a template for my bash scripts command-line parsing, but I like to stick to GNU-style options and I find that Bash's getopts command handles all these cases without trouble:

command -ffilename -f filename --file=filename -- -f is not an option

My template is at https://gist.github.com/webb/ff380b0eee96dafe1c20c2a136d85ef....

1 comments

Using `-:` to build long-options on top of the short-option-only `getopts` builtin is a great hack.
Thanks!