From 84e5beada4d169ad7385ac7b9c55d29578d57b4e Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 3 Dec 2019 21:22:16 +0100 Subject: [PATCH] "~/" does not work as hoped for i.e. it is expanded only by a shell, not a system call, so ~/.config/kbtui.toml was never used. --- cmdConfig.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmdConfig.go b/cmdConfig.go index a32373d..7b7b512 100644 --- a/cmdConfig.go +++ b/cmdConfig.go @@ -50,7 +50,7 @@ func cmdConfig(cmd []string) { func readConfig(filepath ...string) (*Config, error) { var result = new(Config) - var configFile string + var configFile, path string var env bool // Load default config first, this way any values missing from the provided config file will remain the default value @@ -61,8 +61,13 @@ func readConfig(filepath ...string) (*Config, error) { case 0: configFile, env = os.LookupEnv("KBTUI_CFG") if !env { - configFile = "~/.config/kbtui.toml" - if _, err := os.Stat(configFile); os.IsNotExist(err) { + path, env = os.LookupEnv("HOME") + if env { + configFile = path + "/.config/kbtui.toml" + if _, err := os.Stat(configFile); os.IsNotExist(err) { + configFile = "kbtui.toml" + } + } else { configFile = "kbtui.toml" } }