local-exec
usage inherently draws in details of the platform where you are running Terraform, which is one of the reasons why it should be treated as a last resort.
Terraform does not include any built-in way for a module to detect the host operating system. A custom Terraform provider could potentially offer a data source which returns that information, although if one were writing a Terraform provider anyway it may be more appropriate to write one to do whatever operation this provisioner would've been running directly, and thus avoid the need for the Terraform configuration to branch based on operating system.