I have a bash script that uses several variables (name them $fooand $bar). Right now, the script defines them on top with hard-coded values, such as:
foo=fooDefault
bar=barDefault
....
I want to use a script like any of them:
myscript
myscript -foo=altFoo
myscript -bar=altBar
myscript -bar=altBar -foo=altFoo
An ideal solution would allow me to simply list the variable that I want to check for flags.
Is there a good way to do this?
I saw getopt, and I think that this can do about 70% of what I'm looking for, but I'm wondering if there is any tool or india that builds on it or the like that does the rest.
source
share