Cygwin Platform Identification
Brian Inglis
Brian.Inglis@SystematicSw.ab.ca
Wed Feb 9 10:01:59 GMT 2022
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.]
More information about the Cygwin
mailing list