Encapsulate ENV["SHELL"] usage
This commit is contained in:
parent
e78665f4f7
commit
8ada737d40
@ -44,16 +44,18 @@ module Homebrew
|
||||
ENV["VERBOSE"] = "1" if args.verbose?
|
||||
|
||||
if args.cmd.present?
|
||||
safe_system(ENV["SHELL"], "-c", args.cmd)
|
||||
safe_system(preferred_shell, "-c", args.cmd)
|
||||
elsif args.named.present?
|
||||
safe_system(ENV["SHELL"], args.named.first)
|
||||
safe_system(preferred_shell, args.named.first)
|
||||
else
|
||||
subshell = if ENV["SHELL"].include?("zsh")
|
||||
"PS1='brew %B%F{green}%~%f%b$ ' #{ENV["SHELL"]} -d -f"
|
||||
elsif ENV["SHELL"].include?("bash")
|
||||
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]} --noprofile --norc"
|
||||
shell_type = Utils::Shell.preferred
|
||||
subshell = case shell_type
|
||||
when :zsh
|
||||
"PS1='brew %B%F{green}%~%f%b$ ' #{preferred_shell} -d -f"
|
||||
when :bash
|
||||
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{preferred_shell} --noprofile --norc"
|
||||
else
|
||||
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]}"
|
||||
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{preferred_shell}"
|
||||
end
|
||||
puts <<~EOS
|
||||
Your shell has been configured to use Homebrew's build environment;
|
||||
|
||||
@ -291,12 +291,12 @@ module Kernel
|
||||
ENV["HOMEBREW_DEBUG_INSTALL"] = f.full_name
|
||||
end
|
||||
|
||||
if ENV["SHELL"].include?("zsh") && (home = Dir.home).start_with?(HOMEBREW_TEMP.resolved_path.to_s)
|
||||
if Utils::Shell.preferred == :zsh && (home = Dir.home).start_with?(HOMEBREW_TEMP.resolved_path.to_s)
|
||||
FileUtils.mkdir_p home
|
||||
FileUtils.touch "#{home}/.zshrc"
|
||||
end
|
||||
|
||||
Process.wait fork { exec ENV.fetch("SHELL") }
|
||||
Process.wait fork { exec preferred_shell }
|
||||
|
||||
return if $CHILD_STATUS.success?
|
||||
raise "Aborted due to non-zero exit status (#{$CHILD_STATUS.exitstatus})" if $CHILD_STATUS.exited?
|
||||
@ -608,6 +608,11 @@ module Kernel
|
||||
end
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def preferred_shell
|
||||
ENV.fetch("SHELL", "/bin/sh")
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def shell_profile
|
||||
Utils::Shell.profile
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user