diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-09-21 20:25:51 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-10-23 11:15:37 -0700 |
commit | 8c093003c4defcc02e21f19ce812b065afecc277 (patch) | |
tree | a7f4a71a11f2c1f99b40c373aa7b5f48f5eaaa73 /src/connection.lisp | |
parent | ea1277a98705009c94ff7baf3808992bbdcda988 (diff) | |
download | consfigurator-8c093003c4defcc02e21f19ce812b065afecc277.tar.gz |
find XDG_CACHE_HOME without relying on HOME
CONNECTION-CONNATTR for :REMOTE-HOME avoids relying on the HOME environment
variable having the correct value; its docstring describes a case in which
HOME's value can be incorrect. As determining :XDG-CACHE-HOME depends in most
cases on having the correct value for the remote home directory, don't rely on
the HOME environment variable here either.
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection.lisp')
-rw-r--r-- | src/connection.lisp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/connection.lisp b/src/connection.lisp index 8cd3a00..b01f298 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -246,9 +246,11 @@ login(1)). Tilde expansion works correctly." (defmethod connection-connattr ((connection connection) (k (eql :XDG-CACHE-HOME))) - (ensure-directory-pathname - (stripln - (connection-run connection "echo ${XDG_CACHE_HOME:-$HOME/.cache}" nil)))) + (let ((env (stripln (connection-run connection "echo $XDG_CACHE_HOME" nil)))) + (if (plusp (length env)) + (ensure-directory-pathname env) + (merge-pathnames ".cache/" + (connection-connattr connection :remote-home))))) ;;;; Functions to access the slots of the current connection |