Although you can avoid - in the template, the reason is that it does not work: grep leads to the idea that > (part of the template -> ) is the option passed to it, since grep does not have the > option, it complains.
The correct way is to tell grep to stop the pending options by adding -- :
cat a.txt | grep -ri -- '->'
source share