description: a template for option parsing in Bash based on getopt
---
@ -16,6 +16,11 @@ See [this](https://www.mariusvw.com/2013/02/24/bash-getopt-versus-getopts/)
and [this](http://abhipandey.com/2016/03/getopt-vs-getopts/) for a comparison
between the two.
*Please note that the documentation and source code reported here are old.
Refer to the [fbopt](https://github.com/frnmst/fbopt) repository.*
## Reason
To avoid reinventing the wheel and confusion, I have written some notes and a
dummy script that will serve as template. The script is called `fbopt`, i.e:
*Franco Bash Option Parsing Template*. The purpose of this is to change
@ -47,8 +52,8 @@ These elements should be common sense and not be specific to `fbopt`
|------------|---------|-------|
| constants are enclosed within single quotes | `'constant'` | elements within single quotes (only) are not interpreted by the shell |
| variables enclosed within double quotes | `"${variable}"` | double quotes serve as a delimiter between multiple variable names if these are consecutive. Every variable between the quotes is interpolated |
| variables use the curly braces notation | `"${variable}"` | curly braces serve as a delimiter between multiple variable names if these are consecutive. |
| variables not enclosed within double quotes | `${?}` or `for v in ${values}; do echo "${v}"; done`| the only variables allowed without double quotes are integers (such as return values) and loop iterators (because these won't work otherwise) |
| variables use the curly braces notation | `"${variable}"` | curly braces serve as a delimiter between multiple variable names if these are consecutive |
| variables not enclosed within double quotes | `${?}` or `for v in ${values}; do echo "${v}"; done`| the only variables allowed without double quotes are integers (such as return values) and loop iterators (because these won't work otherwise) |
## Dependencies and compliancy
@ -63,7 +68,7 @@ The template is known to work with the following packages
| Package | Package version | fbopt version |
|---------|-----------------|---------------|
| GNU Bash | `GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)` | `0.1`, `0.2` |
| GNU Bash | `GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)` | `0.1`, `0.2`, `0.3` |