I didn't check you patch in deep, but you should consider that the
special meaning of "!" isn't implemented in the original Bourne
Shell[1].
IIRC this or something similar was brought up some time ago and the
result was, that your script has to do the negation if needed.
Best regards
Uwe
[1] login@~ > uname -a
SunOS login 5.10 Generic_118833-36 sun4u sparc
login@~ > /bin/sh -c "! true"
/bin/sh: !: not found
--
Uwe Kleine-K