Early return if Shell#profile's preferred is nil

This commit is contained in:
Issy Long 2025-01-22 12:01:28 +00:00
parent f3a68b616c
commit 34b4cc796f
No known key found for this signature in database

View File

@ -67,7 +67,10 @@ module Utils
return "#{ENV["HOMEBREW_ZDOTDIR"]}/.zshrc" if ENV["HOMEBREW_ZDOTDIR"].present?
end
SHELL_PROFILE_MAP.fetch(preferred, "~/.profile")
shell = preferred
return "~/.profile" if shell.nil?
SHELL_PROFILE_MAP.fetch(shell, "~/.profile")
end
sig { params(variable: String, value: String).returns(T.nilable(String)) }
@ -110,7 +113,7 @@ module Utils
tcsh: "~/.tcshrc",
zsh: "~/.zshrc",
}.freeze,
T::Hash[T.nilable(Symbol), String],
T::Hash[Symbol, String],
)
UNSAFE_SHELL_CHAR = %r{([^A-Za-z0-9_\-.,:/@~+\n])}