]> git.ipfire.org Git - thirdparty/systemd.git/commit
condition: change operator logic to use $= instead of =$ for glob comparisons
authorLennart Poettering <lennart@poettering.net>
Mon, 29 Aug 2022 11:42:44 +0000 (13:42 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Sep 2022 21:16:13 +0000 (23:16 +0200)
commit71a3ff036be64cd9c4f66c02598be58666a1d132
tree0305f8bc88d0c7be5695f199b1e61b017eb8c703
parent06219747f5368909e8006c7b6138aca671a3b9d7
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-*
man/systemd.unit.xml
src/shared/compare-operator.c
src/test/test-condition.c