public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Allen Hewes <allen@decisiv.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: CygwinPaltform Identification
Date: Wed, 9 Feb 2022 06:07:02 +0000	[thread overview]
Message-ID: <MN2PR17MB39990BBDB958E77E7B65B518B82E9@MN2PR17MB3999.namprd17.prod.outlook.com> (raw)
In-Reply-To: <05f301d81d6b$55d8d710$018a8530$@gmail.com>

> -----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.

  reply	other threads:[~2022-02-09  6:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 22:01 Bug Report julie77793
2022-02-08 22:22 ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-02-09  1:46 ` CygwinPaltform Identification Brian Inglis
2022-02-09  4:13   ` julie77793
2022-02-09  6:07     ` Allen Hewes [this message]
2022-02-09  8:10     ` Cygwin Platform Identification Brian Inglis
2022-02-09  9:12   ` CygwinPaltform Identification Henry S. Thompson
2022-02-09 10:01     ` Cygwin Platform Identification Brian Inglis
2022-02-09  6:29 ` Bug Report Ernie Rael
2022-02-09 16:24 ` Bill Stewart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN2PR17MB39990BBDB958E77E7B65B518B82E9@MN2PR17MB3999.namprd17.prod.outlook.com \
    --to=allen@decisiv.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).