How do you determine if you're on a Linux or BSD system inside a script?

This Stack Overflow answer by Nicolas Martyanoff provides a complete solution. I tweaked it to use the newer syntax mentioned in the comments.

Determine the OS:

platform='unknown'
unamestr=$(uname)
if [ "$unamestr" = 'Linux' ]; then
   platform='linux'
elif [ "$unamestr" = 'FreeBSD' ]; then
   platform='freebsd'
fi

Choose the right flags for ls:

if [ "$platform" = 'linux' ]; then

   alias ls='ls --color=auto'

elif [ "$platform" = 'freebsd' ]; then

   alias ls='ls -G'

fi