PeterDP noted that run() does not return a truth value; read a snippet wrong.  push the conditional down into sh land and let the xml parser just always pull the last one (which will be the first one with --limit 1)