CygwinPaltform Identification

Henry S. Thompson ht@inf.ed.ac.uk
Wed Feb 9 09:12:12 GMT 2022


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.



More information about the Cygwin mailing list