Subject: Re: 27.0.50; expand-file-name: default directory expanded twice if relative

From: Paul Eggert <[email-masked]>
Date: Tue, 27 Nov 2018 10:11:34 -0800

On 11/26/18 9:42 PM, Glenn Morris wrote:
> Here's an example of how this can be confusing:
>
> cd /tmp
> mkdir foo
> echo hi > foo/bar
> HOME=foo emacs
> C-x C-f ~/bar   ; works
> M-: (shell-command "ls ~/bar")  ; fails

Yes, and there's a similar confusion in ordinary POSIX shells:

$ cd /tmp
$ mkdir foo
$ echo hi > foo/bar
$ HOME=foo sh
$ cat ~/bar
hi
$ cd
$ cat ~/bar
cat: foo/bar: No such file or directory

The moral of this story in POSIX is "Don't set HOME to a relative file 
name, as it's trouble for any application that chdirs." In your example 
Emacs chdirs; in mine, sh chdirs.

The question is whether Emacs should attempt to insulate users from this 
trouble, presumably by replacing HOME with an absolute directory name 
when HOME's value is relative (or is absent or empty, for that matter). 
The POSIX shell doesn't do that, which is an argument for Emacs not 
doing it either.