On 2017-11-06, Bram Moolenaar wrote:
> Gary Johnson wrote:
> 
> > While reading the discussion of "Security risk of vim swap files,"
> > I decided to review where my swap files were being saved and
> > discovered that my 'directory' setting was not being obeyed.
> > 
> > My 'directory' contains a list of directory names, all ending in
> > "//" on Unix.  All the names beginning with "~" were being ignored,
> > even though they were writable.  I tried finding a simple case to
> > illustrate the problem and discovered that the results depend on
> > whether I set 'directory' with :set or :let.
> > 
> > My home directory contains a tmp directory writable by me.
> > 
> >     $ cd
> >     $ ls -ld tmp
> >     drwxr-xr-x 8 gary gary 8192 Nov  6 10:48 tmp
> > 
> > Case 1:  let
> > 
> >     $ vim -N -u NONE -i NONE --cmd 'let &directory="~/tmp,/tmp"' foo
> >     :set directory?
> >       directory=~/tmp,/tmp
> >     :swapname
> >     /tmp/foo.swp
> > 
> > Case 2: set
> > 
> >     $ vim -N -u NONE -i NONE --cmd 'set directory=~/tmp,/tmp' foo
> >     :set directory?
> >       directory=~/tmp,/tmp
> >     :swapname
> >     /home/gary/tmp/foo.swp
> > 
> > I see no difference between the values of 'directory' whether :set
> > or :let, yet the tilde is expanded correctly when 'directory' is :set
> > and apparently not expanded when 'directory' is :let.
> > 
> > I'm running Vim 8.0.1257 on a system running Red Hat Linux
> > Enterprise Linux 7.2.
> 
> Instead of:
>       :set directory?
> Try this:
>       :echo &directory
> 
> And you'll see what happens.

I see.  Thanks.  I tried to find an explanation in the manual before
posting, but I was searching for "tilde" and missed ":help $HOME".

I don't like that :set? translates the expansion of $HOME to "~" so
that you can't distinguish the translation from a literal "~", but
I don't have a good solution, so I guess it's another one of those
things you just have to be aware of.

Regards,
Gary

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui