diff options
| author | Max Howell | 2012-08-29 19:17:53 -0400 |
|---|---|---|
| committer | Max Howell | 2012-08-29 19:49:11 -0400 |
| commit | 744031b4affdf5f676c1b2f8093746ae0d205b72 (patch) | |
| tree | 111f142d6d3c0276424a08bb50de278b63c25862 /Library/Homebrew/extend/fileutils.rb | |
| parent | e729885ea1c7146572f2b238c37a093a723d7e13 (diff) | |
| download | homebrew-744031b4affdf5f676c1b2f8093746ae0d205b72.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/extend/fileutils.rb')
| -rw-r--r-- | Library/Homebrew/extend/fileutils.rb | 14 |
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. |
