framps / raspiBackup

Create and keep multiple backup versions of your running Raspberries
https://raspibackup.linux-tips-and-tricks.de
GNU General Public License v3.0
815 stars 75 forks source link

Options -h, --help, --version and -? only work if used as the only option #788

Closed rpi-simonz closed 1 month ago

rpi-simonz commented 1 month ago

The options -h, --help, --version and -? only work if used as the only option. Otherwise they cause an error:

root@pi54:/backup/pi54# raspiBackup --version -G EN
??? RBK0089E: Unbekannte Option --version.
--- RBK0091I: 'raspiBackup.sh -h' liefert eine detailierte Beschreibung aller Scriptaufrufoptionen.
--- RBK0026I: Debug Logdatei wurde in /home/chris/raspiBackup.log gesichert.
root@pi54:/backup/pi54# raspiBackup --version
Version: 0.6.9.1 CommitSHA: 77f6bf8 CommitDate: 2024-06-17 CommitTime: 20:55:53

And option -h is treated specially: It's silently ignored and the backup starts anyway.

Suggestions:

Remove the if (( $# == 1 )) here

# handle options which don't require root access
if (( $# == 1 )); then
        if [[ $1 == "-h" || $1 == "--help" || $1 == "--version" || $1 == "-?" ]]; then

and change this here somehow:

        -h|--help)
          HELP=1; break
          ;;

to handle the case when -h (and the others from above) is provided as a second or later option. Not allowed...