hunleyd / btrfs-auto-snapshot

BTRFS Automatic Snapshot Service for Linux
GNU General Public License v2.0
17 stars 4 forks source link

[...]/btrfs-auto-snapshot: line 230: test: freqly: integer expression expected #11

Closed ams-tschoening closed 2 years ago

ams-tschoening commented 2 years ago

I just updated to master and am receiving the following warning:

/usr/local/btrfs-auto-snapshot/btrfs-auto-snapshot: line 230: test: freqly: integer expression expected

The executed command is the following:

/usr/local/btrfs-auto-snapshot/btrfs-auto-snapshot --label=freqly --keep=4  '//'

Reason is the following code:

while test "${label}" -gt 0

-gt has the following docs:

NTEGER1 -gt INTEGER2
INTEGER1 is greater than INTEGER2

So, what's the reason for using while and -gt? I had expected a simple check for an empty string or alike?

                if test -n "${label}"
                then
                    case $label in
                        ([![:alnum:]_.:\ -]*)
                            log error "The $1 parameter must be alphanumeric."
                            argsp_cmdline_exit=${ERR_PREFIX_WRONG}
                            kill -SIGUSR1 $$
                        ;;
                    esac
                    prefix="${prefix#?}"
                fi

The check for --prefix has the same implementation.