grml / grml-rescueboot

32 stars 14 forks source link

Fix '-f' option and getopts optstring. #12

Closed sgf-dma closed 2 years ago

sgf-dma commented 2 years ago

There're a few problems with current optstring:

  1. 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.
  2. 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.
  3. 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.

mika commented 2 years ago

Oh, another nice catch, many thanks! :bow: :+1: