Improve logical conditions between shell commands