GNU-Bash-Shell-Script-Template
GNU-Bash-Shell-Script-Template copied to clipboard
Why reserving '-h' for help option?
The template seems to deliberately reserve -h flag for the predefined --help option. While I appreciate that some shell scripts do use -h for help option (for user convenience), but what's the rationale of imposing it in the template? My concern is that -h could be used for other things depending on application (one use that came to my mind is --no-dereference in utilities such as touch and chown), and applications should be able to let help text be invoked only via the long --help option.
Another problem I observed is when COMMANDLINE_OPTION_DISPLAY_HELP_SHORT is set to empty, then an empty argument string '' might trigger the help text display. What I expected is that it would disable the short option for help text and accept only the long option for help.
The predefined command-line options is merely a reference design and provided to be freely customized by the user (like print_help and process_commandline_arguments these definitions aren't in GBSST's support code at all, it is considered that if one doesn't use it one simply remove the relevant lines in print_help, process_commandline_arguments and COMMANDLINE_OPTION_*)
The reason that COMMANDLINE_OPTION_DISPLAY_HELP_* is separately defined is that it can be (re)used in print_help and process_commandline_arguments, which might be dropped in the future as copying it twice doesn't seem to be a large trade-off.
Hope that answers your question.
I would suggest you drop COMMANDLINE_OPTION_DISPLAY_HELP_* fow two reasons:
- It gives a false sense that user can configure the variable values to anything they like, and the variable names are longer than the contents they hold, and
--helpis probably a fixed convention these days that does not need configurabilty any longer.