I have these two udev rules. They're supposed to match the same thing (any mouse), it's two rules just to troubleshoot/explore.
ACTION=="add", KERNEL=="event[0-9]*", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", RUN+="/usr/local/bin/mouse-middle-click-scroll %s{name} "
ACTION=="add", KERNEL=="event[0-9]*", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ATTRS{name}!="", RUN+="/usr/local/bin/mouse-middle-click-scroll %s{name} "
The only difference is one of them matches on ATTRS{name}!="". I would think the output of udevadm test (and the rule running live) wouldn't change, but it does - I can get the device name from the second rule, but not the first.
colossus /home/bob # udevadm test /dev/input/event15
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
...
run: '/usr/local/bin/mouse-middle-click-scroll '
run: '/usr/local/bin/mouse-middle-click-scroll G309 Mouse '
Unload kernel module index.
Unloaded link configuration context.
Why does this happen?
I also tested this by unplugging my mouse and plugging it back in, once for each rule while the other was commented out, and I can confirm the first rule really only runs once, so it can't be a matter of the second rule having a tighter condition, they must both be hitting the same exact udev thing(event?) but producing different results.