diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-08-29 13:42:44 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-09-01 23:16:13 +0200 |
commit | 71a3ff036be64cd9c4f66c02598be58666a1d132 (patch) | |
tree | 0305f8bc88d0c7be5695f199b1e61b017eb8c703 /man | |
parent | condition: change ConditionKernelVersion= so that =/!= mean literal string co... (diff) | |
download | systemd-71a3ff036be64cd9c4f66c02598be58666a1d132.tar.xz systemd-71a3ff036be64cd9c4f66c02598be58666a1d132.zip |
condition: change operator logic to use $= instead of =$ for glob comparisons
So this is a bit of a bikeshedding thing. But I think we should do this
nonetheless, before this is released.
Playing around with the glob matches I realized that "=$" is really hard
to grep for, since in shell code it's an often seen construct. Also,
when reading code I often found myself thinking first that the "$"
belongs to the rvalue instead of the operator, in a variable expansion
scheme.
If we move the $ character to the left hand, I think we are on the safer
side, since usually lvalues are much more restricted in character sets
than rvalues (at least most programming languages do enforce limits on
the character set for identifiers).
It makes it much easier to grep for the new operator, and easier to read
too. Example:
before:
ConditionOSRelease=ID=$fedora-*
after:
ConditionOSRelease=ID$=fedora-*
Diffstat (limited to 'man')
-rw-r--r-- | man/systemd.unit.xml | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 16aa8303e7..02d5e72aee 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1251,9 +1251,9 @@ <literal>operator</literal> is one of <literal><</literal>, <literal><=</literal>, <literal>>=</literal>, <literal>></literal>, <literal>==</literal>, <literal><></literal> for version comparison, <literal>=</literal> and <literal>!=</literal> - for literal string comparison, or <literal>=$</literal>, <literal>!=$</literal> for shell-style + for literal string comparison, or <literal>$=</literal>, <literal>!$=</literal> for shell-style glob comparison. <literal>value</literal> is the expected value of the SMBIOS field value - (possibly containing shell style globs in case <literal>=$</literal>/<literal>!=$</literal> is + (possibly containing shell style globs in case <literal>$=</literal>/<literal>!$=</literal> is used).</para> </listitem> </varlistentry> @@ -1337,8 +1337,8 @@ expressions. Each expression starts with one of <literal>=</literal> or <literal>!=</literal> for string comparisons, <literal><</literal>, <literal><=</literal>, <literal>==</literal>, <literal><></literal>, <literal>>=</literal>, <literal>></literal> for a relative - version comparison, or <literal>=$</literal>, <literal>!=$</literal> for a shell-style glob - match. If no operator is specified <literal>=$</literal> is implied.</para> + version comparison, or <literal>$=</literal>, <literal>!$=</literal> for a shell-style glob + match. If no operator is specified <literal>$=</literal> is implied.</para> <para>Note that using the kernel version string is an unreliable way to determine which features are supported by a kernel, because of the widespread practice of backporting drivers, features, and @@ -1704,7 +1704,7 @@ with <literal><</literal>, <literal><=</literal>, <literal>==</literal>, <literal><></literal>, <literal>>=</literal>, <literal>></literal>), and shell-style wildcard comparisons (<literal>*</literal>, <literal>?</literal>, <literal>[]</literal>) are - supported with the <literal>=$</literal> (match) and <literal>!=$</literal> (non-match).</para> + supported with the <literal>$=</literal> (match) and <literal>!$=</literal> (non-match).</para> </listitem> </varlistentry> |