I want to make my bash script deal with long parameters. I found getopt
, but it isn\'t supported in OS X. Can anyone tell me why getopt
was implemented
It's generally a better idea to use getopts
instead, and stick with short options. You can see getopts in action in this StackOverflow Q&A. Short options are more standard throughout OSX command line tools, and consistency is a good thing.
Also, getopts is built in to bash, so it's definitely available in OSX, as well as every other platform that can run bash.
Note that there is a getopt
is also available in OSX. From Terminal, type man getopt
to see its documentation. It doesn't support long options. This is a good reason not to use long options when you're writing tools to run on OSX.
If you want to do this anyway, you can install getopt
from macports. Alternately, if you want better portability, you can roll your own long argument handling.
Post some code, and we'll help debug it.