bash logic is hard