You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
617 B
32 lines
617 B
#!/usr/bin/env ruby
|
|
|
|
require 'open3'
|
|
require 'tempfile'
|
|
|
|
def with_tempfile(name)
|
|
file = Tempfile.new(name)
|
|
yield file
|
|
ensure
|
|
file.close
|
|
end
|
|
|
|
plist = ARGF.read
|
|
puts plist or exit unless File.exist?("/usr/libexec/PlistBuddy")
|
|
|
|
with_tempfile('info.plist') do |f|
|
|
f << plist
|
|
f.flush
|
|
|
|
stdout, _, status = Open3.capture3("/usr/libexec/PlistBuddy -c 'Print :variablesdontexport' #{f.path}")
|
|
puts plist or exit unless status.success?
|
|
|
|
vars = stdout.split("\n")[1..-2].map(&:strip)
|
|
|
|
vars.each do |var|
|
|
`/usr/libexec/PlistBuddy -c "Set :variables:#{var} ''" #{f.path}`
|
|
end
|
|
|
|
f.rewind
|
|
puts f.read
|
|
end
|