Usually you can check $^O to find out what OS you are running under.
Under ActivePerl or Strawberry Perl $^O will return MSWin32
C:\>perl -e "print $^O, qq{\n};"
MSWin32
Under Cygwin perl $^O will return cygwin.
$ perl -e "print $^O, qq{\n};"
cygwin
This of course becomes slightly tricky when one runs ActivePerl or Strawberry Perl under the Cygwin environment or Cygwin perl under cmd.exe
The Cygwin environment inherits all the environment variables from the Windows environment. But it appears to set several BASH related vars:
BASH=/cygdrive/c/GNUWin32/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="39" [3]="20"[4]="release" [5]="i68
+6-pc-cygwin")
BASH_VERSION='3.2.39(20)-release'
So to check whether you are running under Cygwin you could use a combination of checking $^O and $ENV{BASH_VERSION} etc. |