aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/pathname.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 8b690a258..5534cd752 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -238,6 +238,16 @@ class Pathname
def / that
join that.to_s
end
+
+ def ensure_writable
+ saved_perms = unless writable?
+ chmod 0644
+ stat.mode
+ end
+ yield
+ ensure
+ chmod saved_perms if saved_perms
+ end
end
# sets $n and $d so you can observe creation of stuff