aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/pkg.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-10 08:24:40 +0100
committerMarkus Reiter2017-03-11 10:47:39 +0100
commit642e355b4f042de80a78036f66d5810dc392cfdc (patch)
tree282d9f0046e6abff79fdfa4a98e95c12c6122662 /Library/Homebrew/cask/lib/hbc/pkg.rb
parent9393b16930740f16a8749d006e5acf3f52d8e5fb (diff)
downloadbrew-642e355b4f042de80a78036f66d5810dc392cfdc.tar.bz2
Save flags in `with_full_permissions`.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/pkg.rb')
-rw-r--r--Library/Homebrew/cask/lib/hbc/pkg.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb
index 102755c53..902d56449 100644
--- a/Library/Homebrew/cask/lib/hbc/pkg.rb
+++ b/Library/Homebrew/cask/lib/hbc/pkg.rb
@@ -92,12 +92,14 @@ module Hbc
def with_full_permissions(path)
original_mode = (path.stat.mode % 01000).to_s(8)
- # TODO: similarly read and restore macOS flags (cf man chflags)
+ original_flags = @command.run!("/usr/bin/stat", args: ["-f", "%Of", "--", path]).stdout.chomp
+
@command.run!("/bin/chmod", args: ["--", "777", path], sudo: true)
yield
ensure
if path.exist? # block may have removed dir
@command.run!("/bin/chmod", args: ["--", original_mode, path], sudo: true)
+ @command.run!("/usr/bin/chflags", args: ["--", original_flags, path], sudo: true)
end
end