12
5
When I change files in cygwin bash with the sed command, the file gets locked.
Reproduce:
- Open
cmd
andcd
to non-user directory (f.e.temp
) echo aaa > test.txt
- Open in texteditor, add line, try to save => works
%CYGWIN_HOME%\bin\bash -c "sed -i 's/aaa/bbb/' test.txt
"- In texteditor, add another line and try to save => "Access denied"
WTF?! How can I sed a file without locking, or release the file handles afterwards?
Windows security permissions appear to be completely screwed on file:
Permissions before:
Permissions after:
It works however in user directory (
Desktop
)- I checked the file with LockHunter but no process appears to lock the file
- Cygwin FAQ mentions interferences with some programs. It tried uninstalling Antivir and Catalyst and rebooting.
- Trying
UnxTools(crashes),GnuWin32(sed doesn't support inplace substitution),Interex(installer doesn't support W7 Pro) ... * sigh *
2That just sounds like the screwy Windows philosophy 'must protect users from themselves', I see that all the time when trying to mix and match Windows and Cygwin/Linux files. Good luck. – shellter – 2012-02-20T21:51:30.363
+1 lambdor. I checked this behavior in Cygwin and you're right. This is pretty weird. The file isn't locked (i.e. as in it isn't in use). The file permissions read only / read write permissions get modified. – None – 2012-02-20T21:59:29.690
I've used GnuWin32 sed on W7 64bit and had no trouble with in place substitution. It's sed 4.2.1 which I downloaded with the getGnuWin32 project.
– Spencer Rathbun – 2012-02-21T13:26:40.610