From 6895ead784e646dbcc3429ce8db14435b84c6035 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 10 Mar 2015 23:26:22 -0400 Subject: Reduce scope of ensure block, remove conditionals --- Library/Homebrew/extend/fileutils.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Library/Homebrew/extend/fileutils.rb') diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb index 76e9b610e..aa1735cb1 100644 --- a/Library/Homebrew/extend/fileutils.rb +++ b/Library/Homebrew/extend/fileutils.rb @@ -14,14 +14,17 @@ module FileUtils # /tmp volume to the other volume. So we let the user override the tmp # prefix if they need to. - tempd = with_system_path { `mktemp -d #{HOMEBREW_TEMP}/#{prefix}-XXXXXX` }.chuzzle - raise "Failed to create sandbox" if tempd.nil? + tempd = with_system_path { `mktemp -d #{HOMEBREW_TEMP}/#{prefix}-XXXXXX` }.strip + raise "Failed to create sandbox" if tempd.empty? prevd = pwd - cd tempd - yield - ensure - cd prevd if prevd - ignore_interrupts{ rm_r tempd } if tempd + cd(tempd) + + begin + yield + ensure + cd(prevd) + ignore_interrupts { rm_r(tempd) } + end end module_function :mktemp -- cgit v1.2.3