Apply shell scripting conventions to improve robustness and consistency:
- Enable `set -u` (nounset) to catch unset variable references early
- Add trap-based cleanup for temporary files instead of manual rm
- Use `readonly` for constants (CHART_FILE, RC_PATTERN)
- Replace `[ ]` with `[[ ]]` throughout for modern bash conditionals
- Use `read -r` to prevent backslash interpretation
- Use `${1:-}` / `${2:-}` for safe positional parameter access under nounset
- Normalize stderr redirect to `>&2`
- Remove `function` keyword, align `;;` in case statements
Co-authored-by: Copilot <copilot@github.com>