>_ IzzyLab

Topic breakdown

A script receives command-line arguments in the positional parameters, and their count in the special variable $#. A numeric comparison is done with the [ ... ] test and operators like -eq, -ge, -lt. Diagnostics and hints are conventionally sent not to stdout but to the error stream (the >&2 redirection), so they don't get mixed in with useful output. The exit code (exit N) is how a script reports success (0) or an error (non-zero code) to its caller.

What's checked

  1. with an argument, exits with code 0
  2. without an argument: usage on stderr and code 1

What it looks like