handle empty captures

At some point after May 2014, our environment changed and matches with
multiple captures started returning empty strings where before they
apparently returned `nil`. Update the various commands checking for nil
to handle either nil or the empty string.