if [ $OS = Linux ]
then
something
else
if [ $OS = FreeBSD ]
then
something
else
if [ $OS = NetBSD ]
then
something
if [ $OS = OpenBSD ]
then
something
fi
fi
fi
I know this can be shorter.. It's a brainfarting Monday
if [ $OS = *BSD ] or so
Use case:
case "$OS" in
*BSD) ...
Regards
Dimitre
case `uname` in
Linux*) # do something Linuxy ;;
FreeBSD*) # do something Freeby ;;
NetBSD*) # do something Netty ;;
OpenBSD*) # do something Openly ;;
*) # do something else ;;
esac
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
The shortest it can be made is to use someone else's code.
"config.guess.sh; config.sub.sh"
http://cvs.savannah.gnu.org/viewcvs/config/config/config.{guess,sub}
"archit.sh"
http://www.cs.indiana.edu/~kinzler/home/binp/archit
"opsys.sh"
http://www.cs.indiana.edu/~kinzler/home/binp/opsys
"platform.sh"
in GNU shtools
"whatami.sh"
component of http://www-unix.mcs.anl.gov/systems/software/msys/
"archguess.sh"
http://sourceforge.net/projects/archguess/
and, of limited applicability,
"shtype"
http://shelldorado.com/scripts/cmds/shtype.txt
and my own "whichshell"
http://groups.google.com/group/comp.unix.shell/browse_frm/thread/2bd63afd15f87c43/01513a857080ed64?lnk=st&q=&rnum=1&hl=en#01513a857080ed64
P.S. You may wish to investigate the "canonical" solution: the
autoconf app which "automatically configures shell scripts ... to
adapt ... to many kinds of UNIX-like systems without manual
user intervention."
http://www.gnu.org/software/autoconf/
=Brian