Dont use a global var for mocking

This commit is contained in:
Kovid Goyal
2025-01-05 20:58:33 +05:30
parent 86a6685446
commit 795bf7fb52
3 changed files with 8 additions and 8 deletions

View File

@@ -403,9 +403,12 @@ func ReloadConfigInKitty(in_parent_only bool) error {
var OverrideEffectiveConfigPath string
func ReadKittyConfig(line_handler func(key, val string) error) error {
func ReadKittyConfig(line_handler func(key, val string) error, override_effective_config_path ...string) error {
kp := os.Getenv("KITTY_PID")
kitty_conf_path := OverrideEffectiveConfigPath
kitty_conf_path := ""
if len(override_effective_config_path) > 0 {
kitty_conf_path = override_effective_config_path[0]
}
if _, err := strconv.Atoi(kp); err == nil && kitty_conf_path == "" {
effective_config_path := filepath.Join(utils.CacheDir(), "effective-config", kp)
if unix.Access(effective_config_path, unix.R_OK) == nil {