From 372315b1381e288bc74314be9acec17b7cf97aec Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 29 May 2023 08:54:49 +0200 Subject: [PATCH] pass: make home-dir resolution platform agnostic Use stdlib's os.UserHomeDir() instead of depending only on $HOME. Note that this does not yet does nss lookups for situations where $HOME / $USERPROFILE is not set. Signed-off-by: Sebastiaan van Stijn --- pass/pass.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pass/pass.go b/pass/pass.go index 61e86fb..80af37d 100644 --- a/pass/pass.go +++ b/pass/pass.go @@ -13,6 +13,7 @@ import ( "os" "os/exec" "path" + "path/filepath" "strings" "sync" @@ -107,7 +108,8 @@ func getPassDir() string { if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" { return passDir } - return os.ExpandEnv("$HOME/.password-store") + home, _ := os.UserHomeDir() + return filepath.Join(home, ".password-store") } // listPassDir lists all the contents of a directory in the password store.