aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorDaniel Patterson <me@danielpatterson.dev>2022-03-02 03:39:01 +0000
committerRobin Jarry <robin@jarry.cc>2022-03-03 21:31:32 +0100
commitc77a1c5d9d635c7ddf515f732699f4346445d058 (patch)
tree2156fc97842d8cc1a67bd426a61f6451474bb8bc /config
parent0cfffaef5409f99bbc4140b97b769a400b7467f8 (diff)
downloadaerc-c77a1c5d9d635c7ddf515f732699f4346445d058.tar.gz
config: expand tilde in search directories
Will expand a user-provided custom sharedir, XDG_CONFIG_HOME and XDG_DATA_HOME if necessary. Will not alter those strings if they do not begin with a tilde. Signed-off-by: Daniel Patterson <me@danielpatterson.dev> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config')
-rw-r--r--config/config.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/config/config.go b/config/config.go
index f5d43ec4..3fecb360 100644
--- a/config/config.go
+++ b/config/config.go
@@ -20,6 +20,7 @@ import (
"github.com/go-ini/ini"
"github.com/imdario/mergo"
"github.com/kyoh86/xdg"
+ "github.com/mitchellh/go-homedir"
"git.sr.ht/~rjarry/aerc/lib/templates"
)
@@ -311,13 +312,20 @@ func buildDefaultDirs() []string {
// Add XDG_CONFIG_HOME and XDG_DATA_HOME
for _, v := range prefixes {
if v != "" {
+ v, err := homedir.Expand(v)
+ if err != nil {
+ log.Println(err)
+ }
defaultDirs = append(defaultDirs, path.Join(v, "aerc"))
}
}
// Add custom buildtime shareDir
if shareDir != "" && shareDir != "/usr/local/share/aerc" {
- defaultDirs = append(defaultDirs, shareDir)
+ shareDir, err := homedir.Expand(shareDir)
+ if err == nil {
+ defaultDirs = append(defaultDirs, shareDir)
+ }
}
// Add fixed fallback locations