It seems that when saving a file in Linux (ubuntu 11.04) Sublime Text 2 writes to the disk twice.
The specific issue this causes for me is that it causes a problem when using guard https://github.com/guard/guard to monitor my source tree for changes. Guard (on linux) uses rb-inotify to watch for changes and then fires events such as building coffeescript, scss, or triggering a livereload event in your browser.
Here is the bit of ruby i was using to test with:
require 'rb-inotify'
notifier = INotify::Notifier.new
notifier.watch(".", :modify) do |event|
puts "Catched event #{ event.inspect }"
end
notifier.run
Here are the events it was triggering:
Catched event #<INotify::Event:0x7fde939252b0 @notifier=#<INotify::Notifier:0x7fde95035f18 @watchers={1=>#<INotify::Watcher:0x7fde93925558 @path="coffee", @notifier=#<INotify::Notifier:0x7fde95035f18 ...>, @flags=:modify], @callback=#<Proc:0x00007fde95036828@test.rb:5>, @id=1>}, @stop=false, @fd=3>, @related=], @native=#<INotify::Native::Event:0x7fde93925260>, @watcher_id=1, @name="script.coffee", @cookie=0, @watcher=#<INotify::Watcher:0x7fde93925558 @path="coffee", @notifier=#<INotify::Notifier:0x7fde95035f18 @watchers={1=>#<INotify::Watcher:0x7fde93925558 ...>}, @stop=false, @fd=3>, @flags=:modify], @callback=#<Proc:0x00007fde95036828@test.rb:5>, @id=1>>
Catched event #<INotify::Event:0x7fde93924590 @notifier=#<INotify::Notifier:0x7fde95035f18 @watchers={1=>#<INotify::Watcher:0x7fde93925558 @path="coffee", @notifier=#<INotify::Notifier:0x7fde95035f18 ...>, @flags=:modify], @callback=#<Proc:0x00007fde95036828@test.rb:5>, @id=1>}, @stop=false, @fd=3>, @related=], @native=#<INotify::Native::Event:0x7fde93922d30>, @watcher_id=1, @name="script.coffee", @cookie=0, @watcher=#<INotify::Watcher:0x7fde93925558 @path="coffee", @notifier=#<INotify::Notifier:0x7fde95035f18 @watchers={1=>#<INotify::Watcher:0x7fde93925558 ...>}, @stop=false, @fd=3>, @flags=:modify], @callback=#<Proc:0x00007fde95036828@test.rb:5>, @id=1>>
Let me know if there is any more info i can provide to track this down.