public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Bug Report
@ 2022-02-08 22:01 julie77793
  2022-02-08 22:22 ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: julie77793 @ 2022-02-08 22:01 UTC (permalink / raw)
  To: cygwin

Cygwin doesn't create an environment variable in bash to indicate that the
platform is Cygwin under Windows.

This causes compatibility problems when running various tools. Most of my
issues have been with Python tools running Windows Python.

I have been addressing this issue by grepping PATH for cygdrive which
doesn't seem like a very good approach.

Both msys2 and mingw solve this issue by setting the MSYSTEM environment
variable which lets tools check that OS=Windows_NT and MSYSTEM=MSYS

Please add some way of identifying that programs are running under Cygwin.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [EXTERNAL] Bug Report
  2022-02-08 22:01 Bug Report julie77793
@ 2022-02-08 22:22 ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
  2022-02-09  1:46 ` CygwinPaltform Identification Brian Inglis
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] @ 2022-02-08 22:22 UTC (permalink / raw)
  To: julie77793, cygwin

> Please add some way of identifying that programs are running under Cygwin.

Have you tried to use the "uname" command for the identification purposes?

$ uname
CYGWIN_NT-6.1

$ uname
CYGWIN_NT-10.0

Anton Lavrentiev
Contractor NIH/NLM/NCBI


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: CygwinPaltform Identification
  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 ` Brian Inglis
  2022-02-09  4:13   ` julie77793
  2022-02-09  9:12   ` CygwinPaltform Identification Henry S. Thompson
  2022-02-09  6:29 ` Bug Report Ernie Rael
  2022-02-09 16:24 ` Bill Stewart
  3 siblings, 2 replies; 10+ messages in thread
From: Brian Inglis @ 2022-02-09  1:46 UTC (permalink / raw)
  To: cygwin

On 2022-02-08 15:01, julie77793@gmail.com wrote:
> Cygwin doesn't create an environment variable in bash to indicate that the
> platform is Cygwin under Windows.
> This causes compatibility problems when running various tools. Most of my
> issues have been with Python tools running Windows Python.
> I have been addressing this issue by grepping PATH for cygdrive which
> doesn't seem like a very good approach.
> Both msys2 and mingw solve this issue by setting the MSYSTEM environment
> variable which lets tools check that OS=Windows_NT and MSYSTEM=MSYS
> Please add some way of identifying that programs are running under Cygwin.

I have been switching env/OS/arch/triple dependent profile and rc files 
and sections for years with:

64 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE
cygwin Windows_NT x86_64 x86_64-unknown-cygwin

32 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE
cygwin Windows_NT i686 i686-pc-cygwin

Please note that *only* $OS is exported by default (in the above list), 
so you will have to explicitly export (in profiles) any other shell 
variables you wish to be available to shell subprocesses.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: CygwinPaltform Identification
  2022-02-09  1:46 ` CygwinPaltform Identification Brian Inglis
@ 2022-02-09  4:13   ` julie77793
  2022-02-09  6:07     ` Allen Hewes
  2022-02-09  8:10     ` Cygwin Platform Identification Brian Inglis
  2022-02-09  9:12   ` CygwinPaltform Identification Henry S. Thompson
  1 sibling, 2 replies; 10+ messages in thread
From: julie77793 @ 2022-02-09  4:13 UTC (permalink / raw)
  To: cygwin

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.

-----Original Message-----
From: Cygwin <cygwin-bounces+cygwin=prettywhack.com@cygwin.com> On Behalf Of
Brian Inglis
Sent: Tuesday, February 8, 2022 6:46 PM
To: cygwin@cygwin.com
Subject: Re: CygwinPaltform Identification

On 2022-02-08 15:01, julie77793@gmail.com wrote:
> Cygwin doesn't create an environment variable in bash to indicate that 
> the platform is Cygwin under Windows.
> This causes compatibility problems when running various tools. Most of 
> my issues have been with Python tools running Windows Python.
> I have been addressing this issue by grepping PATH for cygdrive which 
> doesn't seem like a very good approach.
> Both msys2 and mingw solve this issue by setting the MSYSTEM 
> environment variable which lets tools check that OS=Windows_NT and 
> MSYSTEM=MSYS Please add some way of identifying that programs are running
under Cygwin.

I have been switching env/OS/arch/triple dependent profile and rc files and
sections for years with:

64 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE cygwin Windows_NT x86_64
x86_64-unknown-cygwin

32 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE cygwin Windows_NT i686
i686-pc-cygwin

Please note that *only* $OS is exported by default (in the above list), so
you will have to explicitly export (in profiles) any other shell variables
you wish to be available to shell subprocesses.

--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains too much
technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: CygwinPaltform Identification
  2022-02-09  4:13   ` julie77793
@ 2022-02-09  6:07     ` Allen Hewes
  2022-02-09  8:10     ` Cygwin Platform Identification Brian Inglis
  1 sibling, 0 replies; 10+ messages in thread
From: Allen Hewes @ 2022-02-09  6:07 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Bug Report
  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  6:29 ` Ernie Rael
  2022-02-09 16:24 ` Bill Stewart
  3 siblings, 0 replies; 10+ messages in thread
From: Ernie Rael @ 2022-02-09  6:29 UTC (permalink / raw)
  To: cygwin

On 2/8/22 2:01 PM, julie77793@gmail.com wrote:
> Cygwin doesn't create an environment variable in bash to indicate that the
> platform is Cygwin under Windows.
>
> This causes compatibility problems when running various tools. Most of my
> issues have been with Python tools running Windows Python.
>
> I have been addressing this issue by grepping PATH for cygdrive which
> doesn't seem like a very good approach.
>
> Both msys2 and mingw solve this issue by setting the MSYSTEM environment
> variable which lets tools check that OS=Windows_NT and MSYSTEM=MSYS
>
> Please add some way of identifying that programs are running under Cygwin.
>
And of course there's

    $ uname -o
    Cygwin

-ernie


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Cygwin Platform Identification
  2022-02-09  4:13   ` julie77793
  2022-02-09  6:07     ` Allen Hewes
@ 2022-02-09  8:10     ` Brian Inglis
  1 sibling, 0 replies; 10+ messages in thread
From: Brian Inglis @ 2022-02-09  8:10 UTC (permalink / raw)
  To: cygwin

On 2022-02-08 21:13, julie77793@gmail.com wrote:
> On Tuesday, February 8, 2022 6:46 PM, Brian Inglis wrote:
> On 2022-02-08 15:01, julie77793@gmail.com wrote:
>> Cygwin doesn't create an environment variable in bash to indicate that
>> the platform is Cygwin under Windows.
>> This causes compatibility problems when running various tools. Most of
>> my issues have been with Python tools running Windows Python.
>> I have been addressing this issue by grepping PATH for cygdrive which
>> doesn't seem like a very good approach.
>> Both msys2 and mingw solve this issue by setting the MSYSTEM
>> environment variable which lets tools check that OS=Windows_NT and
>> MSYSTEM=MSYS
>> Please add some way of identifying that programs are running under
>> Cygwin.

> I have been switching env/OS/arch/triple dependent profile and rc files and
> sections for years with:
> 
> 64 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE cygwin Windows_NT x86_64
> x86_64-unknown-cygwin
> 
> 32 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE cygwin Windows_NT i686
> i686-pc-cygwin
> 
> Please note that *only* $OS is exported by default (in the above list), so
> you will have to explicitly export (in profiles) any other shell variables
> you wish to be available to shell subprocesses.

> 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.
If you would like information provided, please request the information 
you seek, and you are more likely to get a response.

You are making a series of incorrect statements here based on incorrect 
assumptions due to lack of relevant information.

Did I suggest you had to set any of those variables?

If you would RTFM e.g. "$ info bash var" you would realize that those 
variables named are set by bash, depending on the build target or host 
execution environment.

I said *only* $OS is exported by default, such that it is automatically 
exported to be available in child processes.

The other variables named have not been automatically exported by 
default since bash 2.

You have to explicitly export the other variables named from your bash 
login or bash process execution shell to make them available in child 
process environments.

Other shells may not provide platform identification or use the same 
variable names e.g.

bash $ echo $HOSTTYPE . $MACHTYPE . $OSTYPE . $VENDOR
x86_64 . x86_64-unknown-cygwin . cygwin .

dash $ echo $HOSTTYPE . $MACHTYPE . $OSTYPE . $VENDOR
. . .

mksh $ echo $HOSTTYPE . $MACHTYPE . $OSTYPE . $VENDOR
. . .

posh $ echo $HOSTTYPE . $MACHTYPE . $OSTYPE . $VENDOR
. . .

tcsh $ echo  $HOSTTYPE . $MACHTYPE . $OSTYPE . $VENDOR
x86_64-cygwin . x86_64 . cygwin . unknown

zsh $ echo $HOSTTYPE . $MACHTYPE . $OSTYPE . $VENDOR
. x86_64 . cygwin . pc

in which case utilities may be used or system configuration enquiries 
sysconf(3) may be required.

Cygwin also provides the POSIX mandated outputs:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/uname.html

64 $ uname
CYGWIN_NT-10.0
32 $ uname
CYGWIN_NT-10.0-WOW

and common Linux and BSD extensions (e.g. -o):

64 $ uname -so
CYGWIN_NT-10.0 Cygwin
64 $ uname -rv
3.3.4(0.341/5/3) 2022-01-31 19:35

$ head /proc/version
CYGWIN_NT-10.0-19044 version 3.3.4-341.x86_64 (corinna@calimero) (gcc 
version 11.2.0 20210728 (Fedora Cygwin 11.2.0-2) (GCC) ) 2022-01-31 
19:35 UTC

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: CygwinPaltform Identification
  2022-02-09  1:46 ` CygwinPaltform Identification Brian Inglis
  2022-02-09  4:13   ` julie77793
@ 2022-02-09  9:12   ` Henry S. Thompson
  2022-02-09 10:01     ` Cygwin Platform Identification Brian Inglis
  1 sibling, 1 reply; 10+ messages in thread
From: Henry S. Thompson @ 2022-02-09  9:12 UTC (permalink / raw)
  To: cygwin

Brian Inglis writes:

> On 2022-02-08 15:01, julie77793@gmail.com wrote:
>> Cygwin doesn't create an environment variable in bash to indicate that the
>> platform is Cygwin under Windows.
>> ...
>
> I have been switching env/OS/arch/triple dependent profile and rc files
> and sections for years with:
>
> 64 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE
> cygwin Windows_NT x86_64 x86_64-unknown-cygwin
> ...

When I don't know or can't remember what variable has the information
I want, printenv is my first stop, e.g.

  64> printenv | grep -i cygwin
  Cygwin=server
  PATH=...

As Brian pointed out, that doesn't find what you need, because it only
lists environment variables, but this does:

  64> declare -p | grep -i cygwin
  declare -ar BASH_VERSINFO=([0]="4" [1]="4" [2]="12" [3]="3" [4]="release" [5]="x86_64-unknown-cygwin")
  declare -x Cygwin="server"
  declare -- MACHTYPE="x86_64-unknown-cygwin"
  declare -- OSTYPE="cygwin"
  declare -x PATH=...

ht
-- 
       Henry S. Thompson, School of Informatics, University of Edinburgh
      10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND -- (44) 131 650-4440
                Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
                       URL: http://www.ltg.ed.ac.uk/~ht/
 [mail from me _always_ has a .sig like this -- mail without it is forged spam]

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Cygwin Platform Identification
  2022-02-09  9:12   ` CygwinPaltform Identification Henry S. Thompson
@ 2022-02-09 10:01     ` Brian Inglis
  0 siblings, 0 replies; 10+ messages in thread
From: Brian Inglis @ 2022-02-09 10:01 UTC (permalink / raw)
  To: cygwin

On 2022-02-09 02:12, Henry S. Thompson wrote:
> Brian Inglis writes:
> 
>> On 2022-02-08 15:01, julie77793@gmail.com wrote:
>>> Cygwin doesn't create an environment variable in bash to indicate that the
>>> platform is Cygwin under Windows.
>>> ...
>>
>> I have been switching env/OS/arch/triple dependent profile and rc files
>> and sections for years with:
>>
>> 64 $ echo $OSTYPE $OS $HOSTTYPE $MACHTYPE
>> cygwin Windows_NT x86_64 x86_64-unknown-cygwin
>> ...
> 
> When I don't know or can't remember what variable has the information
> I want, printenv is my first stop, e.g.
> 
>    64> printenv | grep -i cygwin
>    Cygwin=server
>    PATH=...
> 
> As Brian pointed out, that doesn't find what you need, because it only
> lists environment variables, but this does:
> 
>    64> declare -p | grep -i cygwin
>    declare -ar BASH_VERSINFO=([0]="4" [1]="4" [2]="12" [3]="3" [4]="release" [5]="x86_64-unknown-cygwin")
>    declare -x Cygwin="server"
>    declare -- MACHTYPE="x86_64-unknown-cygwin"
>    declare -- OSTYPE="cygwin"
>    declare -x PATH=...

AKA `set` in most shells:

$ set | egrep -i '=[^/\\]*(cygwin|windows)'
BASH_VERSINFO=([0]="4" [1]="4" [2]="12" [3]="3" [4]="release" 
[5]="x86_64-unknown-cygwin")
MACHTYPE=x86_64-unknown-cygwin
OS=Windows_NT
OSTYPE=cygwin
XDG_CURRENT_DESKTOP=X-Cygwin
$ env | egrep -i '=[^/\\]*(cygwin|windows)'
OS=Windows_NT
XDG_CURRENT_DESKTOP=X-Cygwin

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Bug Report
  2022-02-08 22:01 Bug Report julie77793
                   ` (2 preceding siblings ...)
  2022-02-09  6:29 ` Bug Report Ernie Rael
@ 2022-02-09 16:24 ` Bill Stewart
  3 siblings, 0 replies; 10+ messages in thread
From: Bill Stewart @ 2022-02-09 16:24 UTC (permalink / raw)
  To: cygwin

On Tue, Feb 8, 2022 at 3:02 PM julie77793 wrote:

Cygwin doesn't create an environment variable in bash to indicate that the
> platform is Cygwin under Windows.
>

FYI, as a point of decorum: The subject line of this thread is rather
undiplomatic.

(Bug usually means "software should do X but fails in some way," not
"please add feature X.")

Recommended reading: How to ask questions the smart way[1]

[1] http://www.catb.org/~esr/faqs/smart-questions.html

Bill

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-02-09 16:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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