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