diff options
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/--env.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/--env.rb b/Library/Homebrew/cmd/--env.rb index 281175c93..292bcf866 100644 --- a/Library/Homebrew/cmd/--env.rb +++ b/Library/Homebrew/cmd/--env.rb @@ -3,6 +3,7 @@ require "extend/ENV" require "build_environment" +require "utils/shell" module Homebrew def __env @@ -11,12 +12,25 @@ module Homebrew ENV.setup_build_environment ENV.universal_binary if ARGV.build_universal? - if $stdout.tty? + shell_value = ARGV.value("shell") + has_plain = ARGV.include?("--plain") + + if has_plain + shell = nil + elsif shell_value.nil? + # legacy behavior + shell = :bash unless $stdout.tty? + elsif shell_value == "auto" + shell = Utils::Shell.parent_shell || Utils::Shell.preferred_shell + elsif shell_value + shell = Utils::Shell.path_to_shell(shell_value) + end + + env_keys = build_env_keys(ENV) + if shell.nil? dump_build_env ENV else - build_env_keys(ENV).each do |key| - puts "export #{key}=\"#{ENV[key]}\"" - end + env_keys.each { |key| puts Utils::Shell.export_value(shell, key, ENV[key]) } end end end |
