Skip to content
Snippets Groups Projects
Commit 316d8d75 authored by Jack Nagel's avatar Jack Nagel
Browse files

Reduce scope of ensure block, remove conditionals

parent b1495806
No related branches found
No related tags found
No related merge requests found
...@@ -14,14 +14,17 @@ module FileUtils ...@@ -14,14 +14,17 @@ module FileUtils
# /tmp volume to the other volume. So we let the user override the tmp # /tmp volume to the other volume. So we let the user override the tmp
# prefix if they need to. # prefix if they need to.
tempd = with_system_path { `mktemp -d #{HOMEBREW_TEMP}/#{prefix}-XXXXXX` }.chuzzle tempd = with_system_path { `mktemp -d #{HOMEBREW_TEMP}/#{prefix}-XXXXXX` }.strip
raise "Failed to create sandbox" if tempd.nil? raise "Failed to create sandbox" if tempd.empty?
prevd = pwd prevd = pwd
cd tempd cd(tempd)
yield
ensure begin
cd prevd if prevd yield
ignore_interrupts{ rm_r tempd } if tempd ensure
cd(prevd)
ignore_interrupts { rm_r(tempd) }
end
end end
module_function :mktemp module_function :mktemp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment