puts brew command into if else to avoid shell trap

We setup a shell trap at the top of script. Some brew command returns
non zero exit code. We should put them in if else to continue running