Is there a simple way to check if a script is running in Cygwin. We have a script that calls a utility that expects the paths passed to be windows so if we're in Cygwin we have to convert the paths to windows paths.
The Cygwin installation creates a Bash shell along with a UNIX environment by which you can compile and run UNIX-like programs.
Therefore, the full command to run Bash in Cygwin is C:\cygwin64\bin\bash.exe -i -l .
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 stuff
else
# Other UNIX (Linux, etc.) specific stuff
fi
This works with ksh and bash.
#!/bin/ksh
case "$(uname -s)" in
CYGWIN*) echo This is Cygwin ;;
*) echo This is not Cygwin ;;
esac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With