1

Here is -w option description from test's man page :

   -w FILE
          FILE exists and write permission is granted

And as an example is better than a thousand words :

$ ls -ld /home/maxime/.gvfs
dr-x------ 2 maxime maxime 0 Aug  5 22:53 /home/maxime/.gvfs
$ [ -w /home/maxime/.gvfs ] && echo "is writable" 
is writable
$ touch /home/maxime/.gvfs/file
touch: cannot touch `/home/maxime/.gvfs/file': No such file or directory

As you can see, the directory shouldn't be writable : only r and x flags are set. But, test says that I can write in it... First strange thing. Other one is what happens when I try to create a file in it : No such file or directory.

By the way, I'm running the above commands as user "maxime", and I'm using dash from Ubuntu 12.04.

Well, I'm a bit lost here, anyone got an explanation ?

DCMaxxx
  • 2,534
  • 2
  • 25
  • 46
  • Apart from ``test`` resolving to another binary rather than ``/usr/bin/test``, no idea. Could you try ``test -w /home/maxime/.gvfs; echo $?`` and see whether it's 1 or 0 ? – michel-slm Aug 13 '13 at 06:07
  • Here it is : `/usr/bin/test -w /home/maxime/.gvfs ; echo $?`. Output : `0` – DCMaxxx Aug 13 '13 at 06:16

1 Answers1

1

.gvfs is a special file, in fact a virtual file system created by gvfs-fuse-daemon. You should not use it directly.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • 1
    Alright. In fact, in my shell script, I want to find any writable directory in user's home. Should I make an "exception" for `.gvfs` ? – DCMaxxx Aug 13 '13 at 10:38