getopt should be installed by default in most Linux distros, and you can even run it as a command line program. It's quite easy to use on a bashcript. For example, something like:
while getopts "bar" opt; do
case "$opt" in
b) echo "Option b is set"
;;
a) echo "Option a is set"
;;
r) echo "Option r is set"
;;
esac
done
It won't look pretty but it does get the job done. According to "man getopt" it supports things like short & long options and defaults; if you need something more complex, you should probably be using a proper language instead of a bash script.
No comments:
Post a Comment