aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMax Howell2012-08-29 19:17:53 -0400
committerMax Howell2012-08-29 19:49:11 -0400
commit3fbe631b02617323964e178e847d8a58ee8502f3 (patch)
tree282cc88e0b61a7de88a3bd6cd2513ec2fb29cfcc /Library/Homebrew
parente1ff17ed75aff0bed4f95a20284531b6bf6d98b5 (diff)
downloadbrew-3fbe631b02617323964e178e847d8a58ee8502f3.tar.bz2
Block form of chdir can only be used once
If you nest them, the library complains. So let's not do that. /cc @jacknagel
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/extend/fileutils.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb
index 691fbdcd2..60f795700 100644
--- a/Library/Homebrew/extend/fileutils.rb
+++ b/Library/Homebrew/extend/fileutils.rb
@@ -13,12 +13,16 @@ module FileUtils extend self
# If the user has FileVault enabled, then we can't mv symlinks from the
# /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`.chomp)
- raise "Failed to create sandbox: #{tmp}" unless tmp.directory?
- cd(tmp){ yield }
+ tmp = ENV['HOMEBREW_TEMP'].chuzzle || '/tmp'
+ tempd = `/usr/bin/mktemp -d #{tmp}/brew-#{name}-#{version}-XXXX`.chuzzle
+ prevd = pwd
+ cd tempd
+ yield
+ rescue StandardError
+ raise "Failed to create sandbox"
ensure
- ignore_interrupts{ tmp.rmtree } if tmp
+ cd prevd if prevd
+ ignore_interrupts{ rm_r tempd } if tempd
end
# A version of mkdir that also changes to that folder in a block.