vim does not preserve symlink over sshfs

Posted by HighCommander4 on Super User See other posts from Super User or by HighCommander4
Published on 2011-01-06T02:45:30Z Indexed on 2011/01/06 2:55 UTC
Read the original article Hit count: 238

Filed under:
|
|

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?

© Super User or respective owner

Related posts about vim

Related posts about symbolic-link