Updates to follow some Homebrew best practices

Hi,

Here are some changes to migrate to more current features of Homebrew and adhere to best practices.

I will leave some comments in the diff.

Thanks!
It's not possible to modify the environment of the parent process or subsequent child processes using `system`; any changes persist only for the duration of the call to `system`. This is because the environment is a per-process entity.

The correct way to do this is to modify the `ENV` hash, but it isn't clear to me if that's needed, since this code currently does not do anything.