Skip to content

Commit

Permalink
Fix option argument check that is not executed anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
schoettl committed Nov 22, 2023
1 parent 8a2fd45 commit 01e3474
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/restic/cmd_forget.go
Expand Up @@ -136,10 +136,11 @@ func init() {
}

func verifyForgetOptions(opts *ForgetOptions) error {
if opts.Last < -1 || opts.Hourly < -1 || opts.Daily < -1 || opts.Weekly < -1 ||
opts.Monthly < -1 || opts.Yearly < -1 {
// TODO: this seem to have no effect. there is a different error message showing up, e.g. for --keep-last -5
return errors.Fatal("negative values other than -1 are not allowed for --keep-*")
// Negative numbers for these options are not allowed.
if opts.Last < 0 || opts.Hourly < 0 || opts.Daily < 0 || opts.Weekly < 0 ||
opts.Monthly < 0 || opts.Yearly < 0 {
// This seem to have no effect though. The condition is already catched in `Set(s string)`, line 44.
return errors.Fatal("negative values are not allowed for --keep-*")
}

var allKeepWithinXUndefined = true
Expand Down

0 comments on commit 01e3474

Please sign in to comment.