delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/02/09/03:10:41

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4FE773858C83
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=SystematicSw.ab.ca
Authentication-Results: sourceware.org;
spf=none smtp.mailfrom=systematicsw.ab.ca
X-Authority-Analysis: v=2.4 cv=IaOU5Ema c=1 sm=1 tr=0 ts=620376ec
a=oHm12aVswOWz6TMtn9zYKg==:117 a=oHm12aVswOWz6TMtn9zYKg==:17
a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=uZvujYp8AAAA:8 a=cMEdUNkr87gFzZKFO0oA:9
a=QEXdDO2ut3YA:10 a=sB1i47AQKiIA:10 a=SLzB8X_8jTLwj6mN0q5r:22
Message-ID: <6fd2eb5a-bc91-92c5-f447-b755f8b34765@SystematicSw.ab.ca>
Date: Wed, 9 Feb 2022 01:10:20 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.0
Subject: Re: Cygwin Platform Identification
To: cygwin AT cygwin DOT com
References: <337301d81d37$7afda680$70f8f380$@gmail.com>
<f2da839b-5304-2c5d-9e5b-083fadfe3768 AT SystematicSw DOT ab DOT ca>
<05f301d81d6b$55d8d710$018a8530$@gmail.com>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Organization: Systematic Software
In-Reply-To: <05f301d81d6b$55d8d710$018a8530$@gmail.com>
X-CMAE-Envelope: MS4xfApMu2GpkANmR6Zv0T6jRUaI86eoVVs7EI3uGgu0jP8rL7PFLBziaWa2zcpd3TXLYocwJ6rlYsXrtHRbxdibkI3Qnt/TgEAX0mxnbFf0hah7pWnb+CV/
qCFSVkppcShckgSqf4hny8xVr40CcbtD3c7ZLR0vftr6Sy5c4ictu99vSYx3BeJ5vmp5sLModXsrB4Xhz2W5R+5nxcCWgZ2IbuE=
X-Spam-Status: No, score=-1163.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, SPF_HELO_NONE, SPF_NONE, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On 2022-02-08 21:13, julie77793 AT gmail DOT com wrote:
> On Tuesday, February 8, 2022 6:46 PM, Brian Inglis wrote:
> On 2022-02-08 15:01, julie77793 AT gmail DOT 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 AT 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.]

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019