I have a legacy script that depends on the value of $OSTYPE
variable. What this script expects is that on Solaris the value is "SunOS" while on AIX it is "AIX". For Linux it checks the variable against the regex where the uppercased value starts with "LINUX".
I've tried to run this script from Jenkins, and discovered that the values are different: Solaris returns "solaris2.11" while AIX returns "aix7.1.0.0". I ran the echo $OSTYPE
command on exactly the same servers where Jenkins runs the script, and I get "SunOS"/"AIX" instead.
So the main question I have is: what is the source of this difference (how does the system form the value of this variable, and why does Jenkins have different values than just echo ran from bash). A side question is which is the reliable way to use $OSTYPE
.
The variable
OSTYPE
stores the value of OS TYPE in the shell variables. It depends on shell what value it stores.For example, if you are using
bash
, you will get one value ofOSTYPE
variable, inzsh
, some other value and insh
, you may not get any value itself.See the difference below in using
bash
andzsh
.bash
zsh
So, you may need to check what shell
jenkins
is using when you are getting different values ofOSTYPE