Replace ENV["HOME"] with Dir.home
This commit is contained in:
parent
40bbdc659e
commit
e78665f4f7
@ -106,7 +106,7 @@ module Cask
|
||||
+"/Library/LaunchAgents/#{service}.plist",
|
||||
+"/Library/LaunchDaemons/#{service}.plist",
|
||||
]
|
||||
paths.each { |elt| elt.prepend(ENV["HOME"]).freeze } unless with_sudo
|
||||
paths.each { |elt| elt.prepend(Dir.home).freeze } unless with_sudo
|
||||
paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
|
||||
paths.each do |path|
|
||||
command.run!("/bin/rm", args: ["-f", "--", path], sudo: with_sudo)
|
||||
|
||||
@ -96,7 +96,7 @@ module Cask
|
||||
end
|
||||
|
||||
def printable_target
|
||||
target.to_s.sub(/^#{ENV['HOME']}(#{File::SEPARATOR}|$)/, "~/")
|
||||
target.to_s.sub(/^#{Dir.home}(#{File::SEPARATOR}|$)/, "~/")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -241,7 +241,7 @@ module Cask
|
||||
|
||||
def to_h_string_gsubs(string)
|
||||
string.to_s
|
||||
.gsub(ENV["HOME"], "$HOME")
|
||||
.gsub(Dir.home, "$HOME")
|
||||
.gsub(HOMEBREW_PREFIX, "$(brew --prefix)")
|
||||
end
|
||||
|
||||
|
||||
@ -190,7 +190,7 @@ module Cask
|
||||
key = "language"
|
||||
value = T.cast(explicit.fetch(:languages, []), T::Array[String]).join(",")
|
||||
end
|
||||
"#{key}: \"#{value.to_s.sub(/^#{ENV['HOME']}/, "~")}\""
|
||||
"#{key}: \"#{value.to_s.sub(/^#{Dir.home}/, "~")}\""
|
||||
end.join(", ")
|
||||
end
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def user_tilde(path)
|
||||
path.gsub(ENV["HOME"], "~")
|
||||
path.gsub(Dir.home, "~")
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
@ -766,7 +766,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def check_for_pydistutils_cfg_in_home
|
||||
return unless File.exist? "#{ENV["HOME"]}/.pydistutils.cfg"
|
||||
return unless File.exist? "#{Dir.home}/.pydistutils.cfg"
|
||||
|
||||
<<~EOS
|
||||
A '.pydistutils.cfg' file was found in $HOME, which may cause Python
|
||||
|
||||
@ -2433,7 +2433,7 @@ class Formula
|
||||
GOCACHE: "#{HOMEBREW_CACHE}/go_cache",
|
||||
GOPATH: "#{HOMEBREW_CACHE}/go_mod_cache",
|
||||
CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache",
|
||||
CURL_HOME: ENV["CURL_HOME"] || ENV["HOME"],
|
||||
CURL_HOME: ENV.fetch("CURL_HOME") { Dir.home },
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -904,7 +904,7 @@ class FormulaInstaller
|
||||
sandbox = Sandbox.new
|
||||
formula.logs.mkpath
|
||||
sandbox.record_log(formula.logs/"build.sandbox.log")
|
||||
sandbox.allow_write_path(ENV["HOME"]) if interactive?
|
||||
sandbox.allow_write_path(Dir.home) if interactive?
|
||||
sandbox.allow_write_temp_and_cache
|
||||
sandbox.allow_write_log(formula)
|
||||
sandbox.allow_cvs
|
||||
|
||||
@ -8,9 +8,9 @@ cask "with-uninstall-script-user-relative" do
|
||||
app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app"
|
||||
|
||||
postflight do
|
||||
File.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH
|
||||
File.write "#{Dir.home}/MyFancyApp.app/uninstall.sh", <<~SH
|
||||
#!/bin/sh
|
||||
/bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app"
|
||||
/bin/rm -r "#{Dir.home}/MyFancyApp.app"
|
||||
SH
|
||||
end
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ module Kernel
|
||||
ENV["HOMEBREW_DEBUG_INSTALL"] = f.full_name
|
||||
end
|
||||
|
||||
if ENV["SHELL"].include?("zsh") && (home = ENV["HOME"])&.start_with?(HOMEBREW_TEMP.resolved_path.to_s)
|
||||
if ENV["SHELL"].include?("zsh") && (home = Dir.home).start_with?(HOMEBREW_TEMP.resolved_path.to_s)
|
||||
FileUtils.mkdir_p home
|
||||
FileUtils.touch "#{home}/.zshrc"
|
||||
end
|
||||
|
||||
@ -49,7 +49,7 @@ module Utils
|
||||
def profile
|
||||
case preferred
|
||||
when :bash
|
||||
bash_profile = "#{ENV["HOME"]}/.bash_profile"
|
||||
bash_profile = "#{Dir.home}/.bash_profile"
|
||||
return bash_profile if File.exist? bash_profile
|
||||
when :zsh
|
||||
return "#{ENV["ZDOTDIR"]}/.zshrc" if ENV["ZDOTDIR"].present?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user