apply part of https://github.com/Homebrew/linuxbrew/pull/64