​Here's an update to the previous patch; the problem seemed to be the use of eq for comparing strings rather than string=.​

It seems to work now.

--