Skip to content

Consider always returning false when checking the version of a file that doesn't exist #60

@Ortham

Description

@Ortham

If a version() or product_version() condition function references a file that does not exist, then it will return true iff the comparison operator is <, <= or !=. The reasoning for that is that:

  • if the file doesn't exist that doesn't mean something has gone wrong, so an error is not appropriate
  • having no condition is obviously not the same as having a condition
  • if having no condition is not equal to any given condition, then (if it's at all comparable) it must be less than or greater than any condition, and it makes slightly more sense to treat it as less than, as (stretching here) if you've got nothing then you've got less than if you had something.
  • it tends to provide better results when a condition is written without thinking about the case where a file doesn't exist

It would be more accurate to say that a lack of a condition is incomparable with any given condition, but there's no way to indicate that, except to always return false no matter the operator used.

A breakdown of the current use of the affected operators across the masterlists is:

  • < is used 247 times
  • <= is used 19 times
  • != is used 7 times

It might be that these uses wouldn't actually be affected by changing the behaviour, e.g. because their condition also checks the file exists, or because it appears in file metadata that is only relevant when the file exists anyway.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions