From c8c415f9f70534ca559c76bcb0c79d77edb02d52 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 28 May 2023 18:42:06 +0200 Subject: [PATCH] pass: fix interpolation of $PASSWORD_STORE_DIR commit a13ff500176e7570239691424050fb46b0a7f05b simplified the handling of env-vars in getPassDir(), but moved interpolation of env-vars to the end of the function. As a result, a custom path passed through `$PASSWORD_STORE_DIR` would now be interpolated, instead of taken as-is. For example; PASSWORD_STORE_DIR=$PWD/world Would now interpolate `$PWD`, instead of using a literal `$PWD`. This patch changes the logic to only expand env-vars for the default location. Signed-off-by: Sebastiaan van Stijn --- pass/pass.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pass/pass.go b/pass/pass.go index 0178ac0..61e86fb 100644 --- a/pass/pass.go +++ b/pass/pass.go @@ -104,11 +104,10 @@ func (p Pass) Delete(serverURL string) error { } func getPassDir() string { - passDir := "$HOME/.password-store" - if envDir := os.Getenv("PASSWORD_STORE_DIR"); envDir != "" { - passDir = envDir + if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" { + return passDir } - return os.ExpandEnv(passDir) + return os.ExpandEnv("$HOME/.password-store") } // listPassDir lists all the contents of a directory in the password store.