
#IS THERE A MAC EQUIVALENT TO WINDOWS SUBSYSTEM FOR LINUX CODE#
I recommend to use this complete bash code lowercase()" If you want to cut corners, uname -m and plain uname will tell you what you want to know on many platforms. So for example, a shell script to reformat mail can call, e.g., $LIB/mailfmt which is a platform-specific executable binary. Then I set a boatload of environment variables. I have platform-specific bin, man, lib, and include directories that get set up based on that. My ~/.profile runs an a script at startup which sets one variable to a string indicating the combination of CPU and operating system. For example, just to keep things simple, I treat i386 through i686, any " Pentium*" and any " AMD*Athlon*" all as x86. Uname with no arguments will name the operating system.Įventually you will have to think about the distinctions between platforms and how fine you want to make them. bin/arch, if it exists, will usually give the type of processor. Uname -m will give the "machine hardware name" on some Unix systems. Uname -p is processor type but is usually unknown on modern Unix platforms. I have a sh script of about 100 lines that works across a very wide variety of Unix platforms: any system I have used since 1988.

Here is similar version used on Travis CI: case $(uname | tr '' '') inĭetecting operating system and CPU type is not so easy to do portably. You can find some practical example in my. bashrc): # Detect the platform (similar to $OSTYPE) See the following script (ready to include in. However it's not recognized by the older shells (such as Bourne shell).Īnother method is to detect platform based on uname command. You can simply use pre-defined $OSTYPE variable e.g.: case "$OSTYPE" in
