To allow inclusion in any project the template is released under the [CC0 1.0 license](https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt).
What follows is `fbopt` version `0.2`.
```shell
#!/bin/bash
#
# fbopt version 0.1
# fbopt version 0.2
#
# Written in 2018 by Franco Masotti/frnmst <franco.masotti@student.unife.it>
#
@ -99,7 +106,8 @@ Options:
-f enable and or set f
with an optional argument
-h, --help print this help
--print-flags print the enabled options
--print-flags print the enabled options. This can also
be used to print the default options
Exit status:
0 if OK,
@ -138,7 +146,7 @@ main()
# Set the options. flag_f has an optional argument.
local getopt_short_options='a:b:c:def::hi'
local getopt_long_options="flag-a:,flag-b:,flag-e,print-flags,help,"
local getopt_long_options='flag-a:,flag-b:,flag-e,print-flags,help,'
# Set the default values for the flags.
local flag_a=''
@ -147,7 +155,6 @@ main()
local flag_d='false'
local flag_e='false'
local flag_f='no'
local print_flags='false'
local program_name="${0}"
opts="$(getopt \
@ -197,6 +204,14 @@ main()
# Everything else after '--' is an argument.
argc="${*}"
# Check that the flags that must be non empty are actually not empty.
# A user might infact circumvent getopt's mechanisms like this
# ./program -flag ''
# This can also be done inside the option parser loop but to avoid nestings
# I prefer it done here.
{ [ -z "${flag_a}" ] \
|| [ -z "${flag_b}" ]; } \
&& getopt_error && return 1
[ "${print_flags}" = 'true' ] \
&& show_flags \
'flag_a' \
@ -207,14 +222,6 @@ main()
'flag_f' \
&& return 0
[ "${help}" = 'true' ] && show_help && return 0
# Check that the flags that must be non empty are actually not empty.
# A user might infact circumvent getopt's mechanisms like this
# ./program -flag ''
# This can also be done inside the option parser loop but to avoid nestings
# I prefer it done here.
{ [ -z "${flag_a}" ] \
|| [ -z "${flag_b}" ]; } \
&& getopt_error && return 1
# From now on you should call a function or an external program