invalid internal item number

You broke a simple law of almost all programming languages: don’t use reserved words as a variable name…

Sure. The problem is DHCP client supplies interface name to the script as variable named “interface” (unlike DHCP server that uses “bindingVariableName” variables). Had to use a proxy variable instead.

I know it’s in the docs (now, when I searched them for reserved variable names), but, honestly, the clash was NOT obvious - from implementation POV I’ve expected variables to be substituted first, in the shell or script interpreter, before the commands are executed (thus no clash is possible - the command sees no variable names), but the commands just inherit script environment and substute variables internally (thus causing clash and this, rather cryptic, error message).

An interesting feature of this internal variable substitution is ability to use values of other properties for inline filtering:

/ip firewall address-list print where address=$comment

Will print all IPv4 firewall address list entries in which the address is the same as the comment.

This, however, seems to work for find and where only.