Ryan is an engineer in the Sacramento Area with a focus in Python, Ruby, and Rust. Bash/Python Exercism mentor. Coding, physics, calculus, music, woodworking. Looking for work!
Hmm. I hadn't heard of getopt. Neat! From just a quick search/read-up, here's what I am seeing people say:
GNU getopt seems like a reasonable alternative that makes long options a little easier. It looks like the syntax may be a little more complicated, but not problematically so. The main complaint I'm seeing is that it is external to Bash, so it's not quite as likely to be as portable as getopts, which is a Bash built-in.
That being said, if it's present on the system you're working on or if you're fine installing it, then it seems like a pretty OK alternative: tidying up the things you miss when you roll your own argument parsing, while still being relatively readable.
It reminds me a little of the Python argparse functionality.
I have read that it has issues with whitespace in arguments, but I can't confirm that without trying it out.
Thanks for sharing! :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hmm. I hadn't heard of
getopt
. Neat! From just a quick search/read-up, here's what I am seeing people say:GNU getopt
seems like a reasonable alternative that makes long options a little easier. It looks like the syntax may be a little more complicated, but not problematically so. The main complaint I'm seeing is that it is external to Bash, so it's not quite as likely to be as portable asgetopts
, which is a Bash built-in.That being said, if it's present on the system you're working on or if you're fine installing it, then it seems like a pretty OK alternative: tidying up the things you miss when you roll your own argument parsing, while still being relatively readable.
It reminds me a little of the Python
argparse
functionality.I have read that it has issues with whitespace in arguments, but I can't confirm that without trying it out.
Thanks for sharing! :)