diff options
| author | Jack Nagel | 2014-11-09 18:17:10 -0600 |
|---|---|---|
| committer | Jack Nagel | 2014-11-09 18:17:10 -0600 |
| commit | 0578f1ff5a5234a4e7ca59c49dc0b0bb414cb78a (patch) | |
| tree | 0f3f894b36ccd790da375bc5ed5235c71dcc299d /Library/Homebrew/extend/pathname.rb | |
| parent | b34fa6cfd870e23c3876394509ed0a5be6c70b1e (diff) | |
| download | brew-0578f1ff5a5234a4e7ca59c49dc0b0bb414cb78a.tar.bz2 | |
Pull initialization code out of begin block
Diffstat (limited to 'Library/Homebrew/extend/pathname.rb')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index e65dc25ef..c57f38774 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -106,27 +106,29 @@ class Pathname def atomic_write content require "tempfile" tf = Tempfile.new(basename.to_s, dirname) - tf.binmode - tf.write(content) - begin - old_stat = stat - rescue Errno::ENOENT - old_stat = default_stat - end + tf.binmode + tf.write(content) - uid = Process.uid - gid = Process.groups.delete(old_stat.gid) { Process.gid } + begin + old_stat = stat + rescue Errno::ENOENT + old_stat = default_stat + end - begin - tf.chown(uid, gid) - tf.chmod(old_stat.mode) - rescue Errno::EPERM - end + uid = Process.uid + gid = Process.groups.delete(old_stat.gid) { Process.gid } - File.rename(tf.path, self) - ensure - tf.close! + begin + tf.chown(uid, gid) + tf.chmod(old_stat.mode) + rescue Errno::EPERM + end + + File.rename(tf.path, self) + ensure + tf.close! + end end def default_stat |
