brlin-tw / GNU-Bash-Shell-Script-Template

Easy-to-use GNU Bash shell script templates for for users to create new scripts.
https://github.com/Lin-Buo-Ren/GNU-Bash-Shell-Script-Template
17 stars 2 forks source link

Why reserving '-h' for help option? #9

Open Explorer09 opened 6 years ago

Explorer09 commented 6 years ago

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.

brlin-tw commented 6 years ago

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.

Explorer09 commented 6 years ago

I would suggest you drop COMMANDLINE_OPTION_DISPLAY_HELP_* fow two reasons:

  1. 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
  2. --help is probably a fixed convention these days that does not need configurabilty any longer.