Fixed bash idempotency logic