Merge pull request #14798 from MikeMcQuaid/deprecate_shell
Deprecate `preferred_shell` and `shell_profile`.
This commit is contained in:
commit
7c15dce285
@ -43,6 +43,8 @@ module Homebrew
|
||||
|
||||
ENV["VERBOSE"] = "1" if args.verbose?
|
||||
|
||||
preferred_shell = Utils::Shell.preferred_path(default: "/bin/bash")
|
||||
|
||||
if args.cmd.present?
|
||||
safe_system(preferred_shell, "-c", args.cmd)
|
||||
elsif args.named.present?
|
||||
|
||||
@ -220,7 +220,7 @@ module Kernel
|
||||
FileUtils.touch "#{home}/.zshrc"
|
||||
end
|
||||
|
||||
Process.wait fork { exec preferred_shell }
|
||||
Process.wait fork { exec Utils::Shell.preferred_path(default: "/bin/bash") }
|
||||
|
||||
return if $CHILD_STATUS.success?
|
||||
raise "Aborted due to non-zero exit status (#{$CHILD_STATUS.exitstatus})" if $CHILD_STATUS.exited?
|
||||
@ -530,11 +530,13 @@ module Kernel
|
||||
|
||||
sig { returns(String) }
|
||||
def preferred_shell
|
||||
ENV.fetch("SHELL", "/bin/sh")
|
||||
odeprecated "preferred_shell"
|
||||
Utils::Shell.preferred_path(default: "/bin/sh")
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def shell_profile
|
||||
odeprecated "shell_profile"
|
||||
Utils::Shell.profile
|
||||
end
|
||||
|
||||
|
||||
@ -85,13 +85,13 @@ describe Utils::Shell do
|
||||
it "supports tcsh" do
|
||||
ENV["SHELL"] = "/bin/tcsh"
|
||||
expect(described_class.prepend_path_in_profile(path))
|
||||
.to eq("echo 'setenv PATH #{path}:$PATH' >> #{shell_profile}")
|
||||
.to eq("echo 'setenv PATH #{path}:$PATH' >> #{described_class.profile}")
|
||||
end
|
||||
|
||||
it "supports Bash" do
|
||||
ENV["SHELL"] = "/bin/bash"
|
||||
expect(described_class.prepend_path_in_profile(path))
|
||||
.to eq("echo 'export PATH=\"#{path}:$PATH\"' >> #{shell_profile}")
|
||||
.to eq("echo 'export PATH=\"#{path}:$PATH\"' >> #{described_class.profile}")
|
||||
end
|
||||
|
||||
it "supports fish" do
|
||||
|
||||
@ -18,9 +18,14 @@ module Utils
|
||||
shell_name.to_sym if %w[bash csh fish ksh mksh sh tcsh zsh].include?(shell_name)
|
||||
end
|
||||
|
||||
sig { params(default: String).returns(String) }
|
||||
def preferred_path(default: "")
|
||||
ENV.fetch("SHELL", default)
|
||||
end
|
||||
|
||||
sig { returns(T.nilable(Symbol)) }
|
||||
def preferred
|
||||
from_path(ENV.fetch("SHELL", ""))
|
||||
from_path(preferred_path)
|
||||
end
|
||||
|
||||
sig { returns(T.nilable(Symbol)) }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user