How to write idempotent Bash scripts (2019)
A better approach is to avoid writing bash scripts. They're just too dangerous, even with "strict mode" (http://redsymbol.net/articles/unofficial-bash-strict-mode/).Better to use Python, or Ruby, or a Rust or Go executable.