Shell script detecting running in Cygwin Shell script detecting running in Cygwin unix unix

Shell script detecting running in Cygwin


You can use the uname utility. From uname(1):

-o, --operating-system
print the operating system

Example code:

if [ `uname -o` = "Cygwin" ]then    # Cygwin specific stuffelse    # Other UNIX (Linux, etc.) specific stufffi


This works with ksh and bash.

#!/bin/kshcase "$(uname -s)" in    CYGWIN*) echo This is Cygwin ;;    *) echo This is not Cygwin ;;esac