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?
|
ENV["VERBOSE"] = "1" if args.verbose?
|
||||||
|
|
||||||
|
preferred_shell = Utils::Shell.preferred_path(default: "/bin/bash")
|
||||||
|
|
||||||
if args.cmd.present?
|
if args.cmd.present?
|
||||||
safe_system(preferred_shell, "-c", args.cmd)
|
safe_system(preferred_shell, "-c", args.cmd)
|
||||||
elsif args.named.present?
|
elsif args.named.present?
|
||||||
|
|||||||
@ -220,7 +220,7 @@ module Kernel
|
|||||||
FileUtils.touch "#{home}/.zshrc"
|
FileUtils.touch "#{home}/.zshrc"
|
||||||
end
|
end
|
||||||
|
|
||||||
Process.wait fork { exec preferred_shell }
|
Process.wait fork { exec Utils::Shell.preferred_path(default: "/bin/bash") }
|
||||||
|
|
||||||
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?
|
||||||
@ -530,11 +530,13 @@ module Kernel
|
|||||||
|
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
def preferred_shell
|
def preferred_shell
|
||||||
ENV.fetch("SHELL", "/bin/sh")
|
odeprecated "preferred_shell"
|
||||||
|
Utils::Shell.preferred_path(default: "/bin/sh")
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
def shell_profile
|
def shell_profile
|
||||||
|
odeprecated "shell_profile"
|
||||||
Utils::Shell.profile
|
Utils::Shell.profile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -85,13 +85,13 @@ describe Utils::Shell do
|
|||||||
it "supports tcsh" do
|
it "supports tcsh" do
|
||||||
ENV["SHELL"] = "/bin/tcsh"
|
ENV["SHELL"] = "/bin/tcsh"
|
||||||
expect(described_class.prepend_path_in_profile(path))
|
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
|
end
|
||||||
|
|
||||||
it "supports Bash" do
|
it "supports Bash" do
|
||||||
ENV["SHELL"] = "/bin/bash"
|
ENV["SHELL"] = "/bin/bash"
|
||||||
expect(described_class.prepend_path_in_profile(path))
|
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
|
end
|
||||||
|
|
||||||
it "supports fish" do
|
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)
|
shell_name.to_sym if %w[bash csh fish ksh mksh sh tcsh zsh].include?(shell_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(default: String).returns(String) }
|
||||||
|
def preferred_path(default: "")
|
||||||
|
ENV.fetch("SHELL", default)
|
||||||
|
end
|
||||||
|
|
||||||
sig { returns(T.nilable(Symbol)) }
|
sig { returns(T.nilable(Symbol)) }
|
||||||
def preferred
|
def preferred
|
||||||
from_path(ENV.fetch("SHELL", ""))
|
from_path(preferred_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T.nilable(Symbol)) }
|
sig { returns(T.nilable(Symbol)) }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user