I just tried the one you are replying to and it worked great on macOS. I frequently use a variant of this on my Mac.
The shell doesn't support anything, it just passes the string to env.
So beware quoting and other delimiters that won't work the way you expect.