Weird. This looks a lot like the esverify command code.  Maybe we should merge them? I think I wrote it, so I'm surprised I wrote something non-trivial like this twice.