From 5f049637d9efab6d4433c34b6f7023cf9cd288d1 Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Thu, 4 Feb 2016 14:46:31 +0100 Subject: [PATCH] ENV: protect against environment being reset We cannot really recover from this, but at least we'll provide a clearer error message than trying to call `exec` with an empty string. --- Library/ENV/4.3/cc | 6 +++++- Library/ENV/scm/git | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index 11d8115088..2c6dc205ee 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -2,6 +2,11 @@ # Make sure this shim uses the same Ruby interpreter that is used by Homebrew. unset RUBYLIB unset RUBYOPT +if [ -z "$HOMEBREW_RUBY_PATH" ] +then + echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2 + exit 1 +fi exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@" #!/usr/bin/env ruby -W0 @@ -308,7 +313,6 @@ end if __FILE__ == $PROGRAM_NAME ##################################################################### sanity - abort "The build-tool has reset ENV. --env=std required." unless ENV["HOMEBREW_BREW_FILE"] if (cc = ENV["HOMEBREW_CC"]).nil? || cc.empty? || cc == "cc" # those values are not allowed diff --git a/Library/ENV/scm/git b/Library/ENV/scm/git index 6124ffe5f5..6d13a33a30 100755 --- a/Library/ENV/scm/git +++ b/Library/ENV/scm/git @@ -2,6 +2,11 @@ # Make sure this shim uses the same Ruby interpreter that is used by Homebrew. unset RUBYLIB unset RUBYOPT +if [ -z "$HOMEBREW_RUBY_PATH" ] +then + echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2 + exit 1 +fi exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@" #!/usr/bin/env ruby -W0