Portability fixes to run Homebrew on Linux systems

This patch makes it possible to run Homebrew on a Linux system. I've kept this patch as small as possible and changed as little as possible. I use Homebrew to install software in my home directory on a Linux system at work for which I don't have root access. Homebrew is perfect for this. Please accept this patch.

Cheers,
Shaun