Subject: Re: bug#47790: 27.2; XDG_DATA_HOME evaluation in move-file-to-trash

From: Eli Zaretskii <[email-masked]>
Date: Thu, 15 Apr 2021 11:20:49 +0300

> From: Thierry Volpiatto <[email-masked]>
> Date: Thu, 15 Apr 2021 10:05:04 +0200
> 
> 
> In `move-file-to-trash` there is this code:
> 
>     (or (getenv "XDG_DATA_HOME")
>         "~/.local/share")
> 
> If XDG_DATA_HOME is not set getenv returns nil and that's fine, if
> XDG_DATA_HOME is set to a file path this path is returned and it's fine
> as well, however if user follow recommendations of
> https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
> and set XDG_DATA_HOME to "$HOME/.local/share" then the above block will
> return this value from getenv which is wrong, `substitute-in-file-name`
> should be used here.
> 
>     (setenv "XDG_DATA_HOME" "$HOME/.local/share")

Is this a valid setting of an environment variable?  IOW, are values
of environment variables allowed to reference other environment
variables, and thus are applications required to recursively expand
the values of environment variables until no references are left?
And, as a corollary, does it mean that '$' in file names are not
supported by environment variables whose values are file names?