Re: [PATCH] Add support for ~/foo style relative paths

Subject: Re: [PATCH] Add support for ~/foo style relative paths

Date: Sat, 02 Nov 2024 19:33:29 +0200

To: Ralph Seichter, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


On Fri, Nov 01 2024, Ralph Seichter wrote:

> * Tomi Ollila:
>
>> IMO only deviation from this can be *not* supporting ~user. ~foo
>> expanding as ${HOME}foo is inconsistent and unexpected...
>
> Fair enough. Still, supporting only the "~/" prefix for ${HOME}/ but
> interpreting "~bob" as ${HOME}/~bob is just as unexpected, don't you
> think?

Well, if shells or emacs cannot do tilde expansion then those just
keept it as is:

  $ HOME=/where/ever sh -c 'echo ~'
  /where/ever

  $ HOME=/where/ever sh -c 'echo ~too'
  /home/too

  $ HOME=/where/ever sh -c 'echo ~nouser'
  ~nouser

a bit shorter for emacs to fit better...

  $ HOME=/x emacs --batch --eval '(message "%s" (expand-file-name "~"))'
  /x

  $ HOME=/x emacs --batch --eval '(message "%s" (expand-file-name "~too"))'
  /home/too

  $ HOME=/x emacs --batch --eval '(message "%s" (expand-file-name "~na"))'
  /home/too/~na

this may happen with zsh -- I don't think it breaks "the rule"

  $ HOME=/where/ever zsh -c 'echo ~nouser'
  zsh:1: no such user or named directory: nouser

>> PS. did you know that e.g. ssh does not expand ~ -> getenv("HOME"),
>> but reads the real directory from passwd database.
>
> If I had to guess, I'd say this was probably done with security concerns
> in mind? Avoid possible shenanigans with a process' environment.
>
> -Ralph
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: