validate_input_packages

View source

validate_input_packages <package>[ <package>[ ...]]

This function takes a list of package names separated by spaces and verifies that:

  • It only contains valid characters
  • Each value is a valid package name

Character validation

An OS-specific pattern will be matched against the package name to decide which characters are valid or invalid by the naming standards its package repository uses.

For example, if the OS is FreeBSD, it will set the following pattern:

invalid_characters_pattern='[^A-Za-z0-9\+_\.-]'

If no OS-specific documentation is found on what are the allowed characters in package names, the obtained package list containing all available packages in the operating system’s main repository should be analyzed to determine what is the current range of characters it uses.

The following allowed character groups have been determined so far:

  • FreeBSD (pkg)
    • uppercase and lowercase letters
    • numbers
    • dashes
    • underscores
    • dots
    • plus signs

Package name validation

Package name validation is performed by checking if each package name is found in the package cache. This list is retrieved by the package manager and should represent the full range of valid packages available in the queried repository.

Outcome

If there is any error in validation, the function will return 1. In the check command, for instance, this will cause the dialog to prompt the user again for valid package names.

If all package names are found in the cache, the function will have a clean exit with code 0, allowing the calling function to continue and perform any actual operations on these packages.