A few facts about POSIX
Over 35 years ago, these problems with software portability led to the emergence of the first POSIX standard in 1988. The acronym was coined by Richard Stallman, who added X" to the end of Portable Operating System Interface. It's meant to provide a specification of the interface that different Unix operating systems should have in common, including programming languages and tools. It's important to note that the interface is portable, and not the implementation.
vorakl
While POSIX certainly isn't perfect, and support for it in various operating systems claiming to support POSIX even less so, there's no denying its success. Even if the dream of 100% source code portability isn't possible under POSIX for applications that are a little more complex than basic CLI tools, there's enough portability that platforms like Linux, the various BSDs, macOS, and others, can share quite a bit of code.
One of my favourite things about POSIX is that it shows up in the most unexpected of places. Windows, for instance, has had various options for POSIX compatibility, some of which straight from Microsoft itself, like the currently well-known Windows Subsystem for Linux, but also mostly forgotten options like the Microsoft POSIX subsystem that shipped with Windows NT until Windows 2000, or the very rudimentary POSIX compatibility in the Windows C Runtime Library and Windows Sockets API.
OS/2 had POSIX compatibility as well, through EMX (Eberhard Mattes eXtender). It gave OS/2 - and MS-DOS - a POSIX API, and even provided access to native OS/2 APIs as well, and could run 32bit applications. You'd be surprised by how many more operating systems offered forms of POSIX compatibility, either out of the box or through first or third party add-ons.