A shell script that should have been a program

A deployment script that had grown to six hundred lines of bash with functions, associative arrays and a retry loop.

the signals, in the order they appeared:

  a function taking four positional arguments
  an associative array used as a struct
  string manipulation that needed a comment
  a retry loop with backoff, written twice
  error handling that could not distinguish between
    "the host is down" and "the command failed"
  and finally: a bug caused by unquoted expansion

any two of these is a warning. all six is a program.

Bash is the right tool for orchestrating commands and the wrong one for anything with data structures, and the boundary is crossed gradually enough that no single commit looks wrong. The rewrite kept the shape — it still shells out to the same commands — and gained typed errors and tests, which is what made the retry logic possible to reason about.