CygwinPaltform Identification

Allen Hewes allen@decisiv.com
Wed Feb 9 06:07:02 GMT 2022


> -----Original Message-----
> From: Cygwin <cygwin-bounces+allen=decisiv.net@cygwin.com> On Behalf
> Of julie77793@gmail.com
> Sent: Tuesday, February 8, 2022 11:13 PM
> To: cygwin@cygwin.com
> Subject: RE: CygwinPaltform Identification
>
> I realize that I can create my own env variables. I just think that Cygwin
> should provide them so that programmers writing software can rely on the
> variable name and value. If there is no consistent value when Cygwin is
> installed then dozens of tools that work on other bash solutions for Windows
> can't be made to work on Cygwin.
>

It does. How much more consistent can you get with what Brian pointed out? OSTYPE would be safe in BASH 4+. And if you wanted to be pedantic, OS and OSTYPE and some regex of MACHTYPE? MSYSTEM isn't portable. Of course, there's always uname.

Cygwin:
$ printf "BASH=%s\nOS=%s\nOSTYPE=%s\nHOSTTYPE=%s\nMACHTYPE=%s\n" "${BASH_VERSION}" "${OS-Unknown}" "${OSTYPE}" "${HOSTTYPE}" "${MACHTYPE}"
BASH=4.4.23(1)-release
OS=Windows_NT
OSTYPE=cygwin
HOSTTYPE=x86_64
MACHTYPE=x86_64-unknown-cygwin

MSYS2:
$ printf "BASH=%s\nOS=%s\nOSTYPE=%s\nHOSTTYPE=%s\nMACHTYPE=%s\n" "${BASH_VERSION}" "${OS-Unknown}" "${OSTYPE}" "${HOSTTYPE}" "${MACHTYPE}"
BASH=5.1.8(1)-release
OS=Windows_NT
OSTYPE=msys
HOSTTYPE=x86_64
MACHTYPE=x86_64-pc-msys

Fedora:
$ printf "BASH=%s\nOS=%s\nOSTYPE=%s\nHOSTTYPE=%s\nMACHTYPE=%s\n" "${BASH_VERSION}" "${OS-Unknown}" "${OSTYPE}" "${HOSTTYPE}" "${MACHTYPE}"
BASH=5.1.0(1)-release
OS=Unknown
OSTYPE=linux-gnu
HOSTTYPE=x86_64
MACHTYPE=x86_64-redhat-linux-gnu

FreeBSD:
$ printf "BASH=%s\nOS=%s\nOSTYPE=%s\nHOSTTYPE=%s\nMACHTYPE=%s\n" "${BASH_VERSION}" "${OS-Unknown}" "${OSTYPE}" "${HOSTTYPE}" "${MACHTYPE}"
BASH=5.1.16(0)-release
OS=Unknown
OSTYPE=freebsd12.2
HOSTTYPE=amd64
MACHTYPE=amd64-portbld-freebsd12.2

And Cygwin Python knows of it's host:
$ python
Python 3.8.12 (default, Sep 10 2021, 16:06:59)
[GCC 11.2.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'CYGWIN_NT-10.0-19044'
>>> platform.release()
'3.3.4-341.x86_64'
>>> quit()

/allen

________________________________

Disclaimer Confidentiality Notice: This e-mail, and any attachments and/or documents linked to this email, are intended for the addressee and may contain information that is privileged, confidential, proprietary, or otherwise protected by law. Any dissemination, distribution, or copying is prohibited. This notice serves as a confidentiality marking for the purpose of any confidentiality or nondisclosure agreement. If you have received this communication in error, please contact the original sender.


More information about the Cygwin mailing list