Output of "${OSTYPE:6}" on old releases of Mac OS X I'm writing a shell script that I want to be theoretically compatible with very old versions of Mac OS X (I say "theoretically", because I lack any super-old machines to actually test with). The script uses the output of ${OSTYPE:6} to determine which release of Mac OS X it's running on.

On a machine running 10.13 High Sierra, echo ${OSTYPE:6} returns 17. On a machine running 10.10 Yosemite, it returns 14. Logic thus suggests that the command would output "15" on 10.11 and "16" on 10.12.

(This is useful, because it allows me to include lines like if [[ ${OSTYPE:6} -ge 14 ]]; then DoThing; fi to run DoThing on any system running Yosemite and newer.)

Does this pattern hold for old releases as well? For example, would the command return "4" on the original 10.0?

I ask because, well, it would be odd to start at 4, so I'm worried that somewhere in history, the number was incremented by a point update.
That sounds very much like it's returning the Darwin version.

Your theory works well from 10.15 Mojave [18] back to 10.2 Jaguar [6] but fails before that, as Darwin was 1.x.x at that point.

There's a full list at Wikipedia - macOS