diff options
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. |
