Organiser of the Edinburgh Language Exchange and The Edinburgh Open Tech Scene |
Full Snack Developer 🥪, Ramen guzzler 🍜, quiche murderer 🥧. A friendly cat.
--longoptions does not exist. The getopts built-in command does not take such options. You may have used some external getopts command (which you might find with which getopts) but your example does not apply to normal systems
And my pet peeve, you're not quoting any of your variables, opening up to bugs galore.
Don't post code you haven't checkd, for pity's sake.
The bash scripting ecosystem is rife enough with bad examples and bad code, we really don't need any more atrocious and unchecked posts about it.
There is so much wrong here, you obviously have not checked your code at all.
case
block, which is a basic syntax error--longoptions
does not exist. Thegetopts
built-in command does not take such options. You may have used some externalgetopts
command (which you might find withwhich getopts
) but your example does not apply to normal systemsDon't post code you haven't checkd, for pity's sake.
The bash scripting ecosystem is rife enough with bad examples and bad code, we really don't need any more atrocious and unchecked posts about it.
I do admit I extracted the first example from a larger script of mine, and the second example came from the Stack Overflow link you linked.
I'll fix the problems you pointed out, thanks for letting me know about them. It's why I have the disclaimer at the end.
Regarding the --longoptions comment though, GNU getopt does have such an option. It's the version I used in the first example.