vim does not preserve symlink over sshfs

1

0

I'm having some trouble with symlinks and sshfs. I use the '-o follow_symlinks' option to follow symlinks on the server side, but whenever I edit a symlinked file on the client side with vim, a copy of it is made on the server side, i.e. it's no longer a symlink.

Set up a symlink on the server side:

me@machine1:~$ echo foo > test.txt
me@machine1:~$ mkdir test
me@machine1:~$ cd test
me@machine1:~/test$ ln -s ../test.txt test.txt
me@machine1:~/test$ ls -al test.txt
lrwxrwxrwx 1 me me 11 Jan  5 21:13 test.txt -> ../test.txt
me@machine1:~/test$ cat test.txt
foo
me@machine1:~/test$ cat ../test.txt
foo

So far so good. Now:

me@machine2:~$ mkdir test
me@machine2:~$ sshfs me@machine1:test test -o follow_symlinks
me@machine2:~$ cd test
me@machine2:~/test$ vim test.txt
[in vim, add a new line "bar" to the file]
me@machine2:~/test$ cat test.txt
foo
bar

Now observe what this does to the file on the server side:

me@machine1:~/test$ ls -al test.txt
-rw-r--r-- 1 me me 19 Jan  5 21:24 test.txt
me@machine1:~/test$ cat test.txt
foo
bar
me@machine1:~/test$ cat ../test.txt
foo

As you can see, it made a copy and only edited the copy.

How can I get it to work so it actually follows the symlink when editing the file?

HighCommander4

Posted 2011-01-06T02:45:30.210

Reputation: 531

is any other programm 'respecting the symlink' either? i mean, vim opens what is given by the filesystem... – akira – 2011-01-06T08:03:23.920

@akira: echo bar >> test.txt on the client machine preserves the symlink – HighCommander4 – 2011-01-06T18:37:15.900

1Is this still an issue? From the question it looks like it's not copying the file, it's dropping the symlink and creating a new file. Would setting -o transform_symlinks be a better alternative? – vol7ron – 2014-03-23T21:28:16.480

No answers