diff options
| author | Jack Nagel | 2014-11-09 18:17:10 -0600 | 
|---|---|---|
| committer | Jack Nagel | 2014-11-09 18:17:10 -0600 | 
| commit | b6c811ba12d9c1dc756781fa90c964ca11c5a8c2 (patch) | |
| tree | 1e8503468059700f41ee5d313e8c0577085d7541 /Library/Homebrew/extend/pathname.rb | |
| parent | 550af8c82fde3bf6b06378000802a43bca452590 (diff) | |
| download | homebrew-b6c811ba12d9c1dc756781fa90c964ca11c5a8c2.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  | 
