Yes and no.
In bash, use $OSTYPE and $HOSTTYPE, as documented; this is what I do. If that is not enough, and if even uname or uname -a (or other appropriate options) does not give enough information, there's always the config.guess script from the GNU project, made exactly for this purpose. You can do this by editing directly the file or using the tee -a command as shown below. me@mac: $ echo $ (brew -prefix)/bin/bash sudo tee -a /private/etc/shells /usr/local/bin/bash me@mac: $ cat /private/etc/shells # List of acceptable shells for chpass (1).
They both have bash, however, not all commands are the same between OS X and Linux, and when the commands are the same, not all the options are the same. But for the most part command options available on OS X will be a subset of the richer set of options on Linux. There will only be a few commands on Linux that do not accept options available on OS X.
Also OS X's bash is version 3.2.57(1), where as Linux is going to have a bash with a 4.something version. 98% of bash behavior will be the same, but there are going to be a few edge conditions where they may behave differently.
NOTE: Commands are separate from bash. Each is their own program and are not tied to each other in anyway.
I live in an OS X, Linux, Solaris, AIX Unix world, and for the most part I can write scripts on one platform and run them on any of the others. Where I have difficulties, I add code along the lines of
UNAME=$(uname)
if [[ $UNAME = 'Linux' ]]; then
.. Linux specific
elif [[ $UNAME = Darwin ]]; then
Turret jumper (prototype) mac os. .. OS X specific
elif [[ $UNAME = AIX ]]; then
.. AIX specific
else
.. generic ..
fi
Watermelon Bash Mac Os Download
The reason OS X has an older version of bash, and why OS X does not include the Linux commands with all the extra options is that many of those programs have a GPL V3 license that explicitly excludes commercial Unix vendors from including them in their operating system distributions, so the commercial Unix companies are stuck with either GPL V2 licensed code, or code they got from BSD distributions, such as FreeBSD (a lot of OS X command are originally from FreeBSD).
Turret jumper (prototype) mac os. .. OS X specific
elif [[ $UNAME = AIX ]]; then
.. AIX specific
else
.. generic ..
fi
Watermelon Bash Mac Os Download
The reason OS X has an older version of bash, and why OS X does not include the Linux commands with all the extra options is that many of those programs have a GPL V3 license that explicitly excludes commercial Unix vendors from including them in their operating system distributions, so the commercial Unix companies are stuck with either GPL V2 licensed code, or code they got from BSD distributions, such as FreeBSD (a lot of OS X command are originally from FreeBSD).
However, if there is an open source command that you really want on your system, you are allowed to install it yourself. I actually build and install my own current version of bash on my OS X systems. The GPL V3 license does not restrict you, only Apple.
Halloween night (zegaren, famicon80) mac os.
There are several package managers that make adding open source commands fairly easy. Homebrew, MacPorts, Fink.
Mac Os Catalina
Dec 3, 2015 8:24 PM