win32 vim and file mode in CYGWIN

18 views
Skip to first unread message

SungHyun Nam

unread,
Aug 24, 2007, 1:05:24 AM8/24/07
to VIM Developers
Hello,

If I edit a file with a win32 vim, then the file mode in
CYGWIN is changed to 0755.

Is it possible win32 vim preserves the file mode in cygwin?

regards,
--
namsh


Fuzzy Logic

unread,
Aug 24, 2007, 8:47:22 AM8/24/07
to vim...@googlegroups.com
Not possible. Win32 vim uses the standard Windows APIs for creating
files. It has no knowledge of cygwin at all. It might be possible to
change cygwin's configuration, but I doubt that.

Fuzzy

Tony Mechelynck

unread,
Aug 24, 2007, 12:27:27 PM8/24/07
to vim...@googlegroups.com

If you know that you will never be creating executables (not even .bat files,
bash shell scripts or perl scripts) in that directory, try

chmod a-x .

in that directory in Cygwin bash. I'm not sure, but I think it might influence
the Cygwin permissions of files created in that directory in the future. (See
"man chmod" and/or "info chmod" for details.)


Best regards,
Tony.
--
NEIL INNES PLAYED: THE FIRST SELF-DESTRUCTIVE MONK, ROBIN'S LEAST FAVORITE
MINSTREL, THE PAGE CRUSHED BY A RABBIT, THE OWNER OF A DUCK
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Frodak Baksik

unread,
Aug 24, 2007, 12:49:48 PM8/24/07
to vim...@googlegroups.com

These types of issues have been discussed before on the Cygwin mailing list.

Essentially the issue is with win32 vim only using the default file
permissions (i.e. Inherit permissions from parent) when writing the
updated file. For the behavior you desire win32 vim would need to be
updated to track the actual NTFS permissions and restore them when
using :write.

--
Frodak

Frodak Baksik

unread,
Aug 24, 2007, 12:57:08 PM8/24/07
to vim...@googlegroups.com

The only problem with that would be you couldn't cd into the directory anymore.

:-)
Frodak

Tony Mechelynck

unread,
Aug 24, 2007, 1:16:41 PM8/24/07
to vim...@googlegroups.com
Frodak Baksik wrote:
[...]

> These types of issues have been discussed before on the Cygwin mailing list.
>
> Essentially the issue is with win32 vim only using the default file
> permissions (i.e. Inherit permissions from parent) when writing the
> updated file. For the behavior you desire win32 vim would need to be
> updated to track the actual NTFS permissions and restore them when
> using :write.
>
> --
> Frodak

Does

:set backupcopy

improve the results?


Best regards,
Tony.
--
"If you ever want to get anywhere in politics, my boy, you're going to
have to get a toehold in the public eye."

Matthew Woehlke

unread,
Aug 24, 2007, 4:29:30 PM8/24/07
to vim...@vim.org
SungHyun Nam wrote:
> If I edit a file with a win32 vim, then the file mode in
> CYGWIN is changed to 0755.
>
> Is it possible win32 vim preserves the file mode in cygwin?

Windows programs don't know about Cygwin file permissions.

If vim is changing the Windows ACL permissions (hint: cacls, or Cygwin's
getfacls), that might be a legitimate bug. Otherwise, use Cygwin's vim :-).

--
Matthew
Help! Someone let me off this crazy thing!

Tony Mechelynck

unread,
Aug 24, 2007, 4:39:25 PM8/24/07
to vim...@googlegroups.com
Sorry if you see this twice: after more than 3 hours I'm not seeing it (nor
any reply to it) on the group.

Frodak Baksik wrote:
[...]


> These types of issues have been discussed before on the Cygwin mailing list.
>
> Essentially the issue is with win32 vim only using the default file
> permissions (i.e. Inherit permissions from parent) when writing the
> updated file. For the behavior you desire win32 vim would need to be
> updated to track the actual NTFS permissions and restore them when
> using :write.
>
> --
> Frodak

Does

Frodak Baksik

unread,
Aug 24, 2007, 5:43:25 PM8/24/07
to vim...@googlegroups.com
On 8/24/07, Tony Mechelynck <antoine.m...@gmail.com> wrote:
>

I checked that backupcopy=auto.

The issue seems to be with the swap file. If I open a file with win32
vim, the swap file gets created with the default permissions. Then
when I write the file, the backup copy has the original permissions
but the new file has the default permissions.

When I tried this scenario with Windows Word, its swap file has the
default permissions, but when the file is saved and word is closed the
original permissions are retained. I also tried it with notepad,
wordpad, and visual studio.

Would this be considered a bug with win32 vim on NTFS or is their
another setting to try?

Thanks,
Frodak

Tony Mechelynck

unread,
Aug 24, 2007, 6:34:53 PM8/24/07
to vim...@googlegroups.com

Try ":set backupcopy=yes", which is the Unix default and ought to work well in
Cygwin, which is a Unix-like environment.

This ought to give default permissions to the backup and keep the file's
original permissions intact. If, in addition, you have, for example,

:set nobackup writebackup

the backup file won't have a very long lifespan, unless there is a problem.


Best regards,
Tony.
--
Religion has done love a great service by making it a sin.
-- Anatole France

Frodak Baksik

unread,
Aug 24, 2007, 8:34:47 PM8/24/07
to vim...@googlegroups.com

This did the trick. When win32 vim wrote the file back the original
NTFS settings were restored.

SungHyun Nam

unread,
Aug 27, 2007, 5:09:57 AM8/27/07
to vim...@googlegroups.com

Thanks! It worked!

Of course my main development env. is CYGWIN, but a application which I
have to use conflicts with CYGWIN. While I use that program and have to
modify/build a project (sources), I had to use win32 VIM. And it gave me
a headache because of file mode changes.

Regards,
namsh

Reply all
Reply to author
Forward
0 new messages