-
Thomas Haller authored
For simple matches like match.interface-name, match.driver, and match.path, arguably what we had was fine. There each element (like "eth*") is a wildcard for a single name (like "eth1"). However, for match.kernel-command-line, the elements match individual command line options, so we should have more flexibility of whether a parameter is optional or mandatory. Extend the syntax for that. - the elements can now be prefixed by either '|' or '&'. This makes optional or mandatory elements, respectively. The entire match evaluates to true if all mandatory elements match (if any) and at least one of the optional elements (if any). As before, if neither '|' nor '&' is specified, then the element is optional (that means, "foo" is the same as "|foo"). - the exclamation mark is still used to invert the match. If used alone (like "!foo") it is a shortcut for defining a mandatory match ("&!foo"). - the backslash can now be used to escape the special characters above. Basically, the special characters ('|', '&', '!') are stripped from the start of the element. If what is left afterwards is a backslash, it also gets stripped and the remainder is the pattern. For example, "\\&foo" has the pattern "&foo" where '&' is no longer treated specially. This special handling of the backslash is only done at the beginning of the element (after the optional special characters). The remaining string is part of the pattern, where backslashes might have their own meaning. This change is mostly backward compatible, except for existing matches that started with one of the special characters '|', '&', '!', and '\\'. (cherry picked from commit 824ad627)