This commit is contained in:
2026-01-11 01:04:39 -08:00
parent 7c1959483f
commit 61ab690604
2 changed files with 32 additions and 14 deletions

View File

@@ -37,7 +37,15 @@ def expand_path(p: str | Path | None) -> Path:
"""Expand ~ and environment variables in path."""
if p is None:
return None # type: ignore
expanded = os.path.expandvars(str(p))
s = str(p)
# Courtesy check for $home -> $HOME if we're on a POSIX-like system
# (where env vars are case-sensitive)
if os.name != 'nt' and '$home' in s and '$HOME' not in os.environ:
# If $home is literally used in config but only HOME is defined
if 'HOME' in os.environ:
s = s.replace('$home', '$HOME')
expanded = os.path.expandvars(s)
return Path(expanded).expanduser()