diff options
| author | Max Howell | 2012-08-23 12:47:36 -0400 |
|---|---|---|
| committer | Max Howell | 2012-08-29 12:41:36 -0400 |
| commit | 1392cd40f83d4e67c34bf840bbac815c28332833 (patch) | |
| tree | e32bde562e2cd7aa5f274a23f8e7c6b2062c9607 /Library/Homebrew | |
| parent | a72397ca8f79a269bef5845d66b221e0ef211195 (diff) | |
| download | homebrew-1392cd40f83d4e67c34bf840bbac815c28332833.tar.bz2 | |
Ensure mktemp cleans up after itself
Ignore interrupts.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/extend/fileutils.rb | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb index 355829720..691fbdcd2 100644 --- a/Library/Homebrew/extend/fileutils.rb +++ b/Library/Homebrew/extend/fileutils.rb @@ -14,16 +14,11 @@ module FileUtils extend self # /tmp volume to the other volume. So we let the user override the tmp # prefix if they need to. tmp_prefix = ENV['HOMEBREW_TEMP'] || '/tmp' - tmp=Pathname.new `/usr/bin/mktemp -d #{tmp_prefix}/homebrew-#{name}-#{version}-XXXX`.strip - raise "Couldn't create build sandbox" if not tmp.directory? or $? != 0 - begin - wd=Dir.pwd - chdir tmp - yield - ensure - chdir wd - tmp.rmtree - end + tmp = Pathname.new(`/usr/bin/mktemp -d #{tmp_prefix}/homebrew-#{name}-#{version}-XXXX`.chomp) + raise "Failed to create sandbox: #{tmp}" unless tmp.directory? + cd(tmp){ yield } + ensure + ignore_interrupts{ tmp.rmtree } if tmp end # A version of mkdir that also changes to that folder in a block. |
