Main changes:
- Invalid flags are not handled. Added a *) case.
- In the unlikely event cd fails, treat as fatal (exit 1)
- Prefer [ p ] && [ q ] as [ p -a q ] is not well defined, c.f. shellcheck SC2166 and its upstream reference to The Open Group Base Specifications.
- Added shellcheck disable=SC3043 to maintain local instead of strict POSIX adherance
- Added shellcheck disable=SC3028 to silence ${HOSTNAME:-$(hostname)} as the present parameter expansion safely handles the case where it's unset and we are not targetting strict POSIX adherance.
Also:
- Use $(...) notation instead of legacy backticks
- Double quote to prevent globbing and word splitting