In addition to what rycamor said, if you're checking for a variable for conditional redirectioning and you have more stuff underneath for nonmatching variables, you can make sure those commands aren't executed by simply adding exit() at the end of your if statement.