>_ IzzyLab

Topic breakdown

Every command returns an exit code: 0 means success, non-zero means an error. && runs the next command only if the previous one returned 0, || — only if it returned non-zero. The idiom cmd && ok || fail replaces a short if, but with a catch: if ok itself fails, fail runs too. grep -q is handy as a condition — it prints nothing and reports the result only through its exit code.

What's checked

  1. script uses && and ||
  2. correct branch when grep succeeds
  3. correct branch when grep fails

What it looks like