Alfonso Baqueiro Bernal
Tuesday, April 12, 2023
[ UP ]

Bash

Bash can be running on linux but also on other implementations and systems like windows or MacOS.

So it become useful for a script to detect where is it running to adapt properly.

There are several ways to do this:

OSTYPE variable

OSTYPE value Environment
echo $OSTYPE
linux-gnu
Linux
echo $OSTYPE
darwin
MacOS
echo $OSTYPE
cygwin
Cygwin on windows
echo $OSTYPE
msys
MinGW (lightweiht shell and GNU utils compiled for windows), Git BASH
? FreeBSD