Option -f does not need an argument. So, there should not be any colon after f. And this is the reason, why e.g. update-grml-rescueboot -f -t small will mistakenly download full iso: option -f eats -t as an argument.
Though options -a and -t defined in optstring as having optional argument, in fact, require argument in code: else branch produces an error and there's no check for empty OPTARG.
And, finally, shell getopts does not support optional arguments (double colon in optstring) at all. So, to make point 2 even possible argument parsing should be rewritten somehow..
But i think it's simpler to just make -a and -t arguments to be required, and here is the fix.
There're a few problems with current optstring:
-f
does not need an argument. So, there should not be any colon afterf
. And this is the reason, why e.g.update-grml-rescueboot -f -t small
will mistakenly downloadfull
iso: option-f
eats-t
as an argument.-a
and-t
defined in optstring as having optional argument, in fact, require argument in code:else
branch produces an error and there's no check for emptyOPTARG
.getopts
does not support optional arguments (double colon in optstring) at all. So, to make point 2 even possible argument parsing should be rewritten somehow..But i think it's simpler to just make
-a
and-t
arguments to be required, and here is the fix.