Bash clone, partially following FOUpdater::UpdateFile scheme (by jan0s1k)