diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 8b690a2581..5534cd7528 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