Change "x && y || z" to "if x then y else z" because it is more robust, see: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3