aurora / rmate

Remote TextMate 2 implemented as shell script
GNU General Public License v3.0
886 stars 123 forks source link

Fix file truncation on save. #7

Closed tornewuff closed 11 years ago

tornewuff commented 11 years ago

dd issues one call to read() per block, so using a large blocksize with a count of 1 means it only calls read() once. Bash's tcp redirection doesn't always seem to return a full buffer in this case (often stopping at 32KB), which results in files being truncated.

Avoid this by using head -c. head will use a sensible buffer size automatically and continue to call read() until exactly the number of bytes requested have been read. This fixes issue #5.

aurora commented 11 years ago

i've just changed this again to use dd=bs=1 count=$value. hopefully you are right and this solves the file truncation problem ...