From e15a797640cb7ed6877921a1c520791f005ecbe8 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Tue, 17 Oct 2023 09:08:36 +0200 Subject: [PATCH] feat(shell): allow user to specify the cache path with OMP_CACHE_DIR resolves #4321 --- src/platform/shell_unix.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/platform/shell_unix.go b/src/platform/shell_unix.go index 6cb9d212..caca352a 100644 --- a/src/platform/shell_unix.go +++ b/src/platform/shell_unix.go @@ -100,14 +100,22 @@ func (env *Shell) Platform() string { func (env *Shell) CachePath() string { defer env.Trace(time.Now()) + + // allow the user to set the cache path using OMP_CACHE_DIR + if cachePath := returnOrBuildCachePath(env.Getenv("OMP_CACHE_DIR")); len(cachePath) != 0 { + return cachePath + } + // get XDG_CACHE_HOME if present if cachePath := returnOrBuildCachePath(env.Getenv("XDG_CACHE_HOME")); len(cachePath) != 0 { return cachePath } + // HOME cache folder if cachePath := returnOrBuildCachePath(env.Home() + "/.cache"); len(cachePath) != 0 { return cachePath } + return env.Home() }