Fix some errors in the bash logic