Check for properly formatted command in sudo()

This fixes bug 2745