aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/man.rb
diff options
context:
space:
mode:
authorMartin Afanasjew2015-12-09 06:07:58 +0100
committerMartin Afanasjew2015-12-13 22:18:27 +0100
commitb0b5d22af1c4ee051d63b31996a3cd70c6ccc947 (patch)
treea2cc45ec145322f4c1ae6f52eea05fa3895be83a /Library/Homebrew/cmd/man.rb
parent4a89cfb1dc75a1fae98809868b26d98eda1f8c6f (diff)
downloadbrew-b0b5d22af1c4ee051d63b31996a3cd70c6ccc947.tar.bz2
man: modernize and reduce code duplication
Also use `popen_read` instead of `safe_system` for cleaner argument passing and write the output with `atomic_write`. Closes Homebrew/homebrew#46826. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Diffstat (limited to 'Library/Homebrew/cmd/man.rb')
-rw-r--r--Library/Homebrew/cmd/man.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb
index e8ac66fd0..a3f95f53f 100644
--- a/Library/Homebrew/cmd/man.rb
+++ b/Library/Homebrew/cmd/man.rb
@@ -26,10 +26,19 @@ module Homebrew
puts "Writing manpages to #{TARGET_PATH}"
Dir["#{SOURCE_PATH}/*.md"].each do |source_file|
- target_html = DOC_PATH/"#{File.basename(source_file, ".md")}.html"
- safe_system "ronn --fragment --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_html}"
- target_man = TARGET_PATH/File.basename(source_file, ".md")
- safe_system "ronn --roff --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_man}"
+ args = %W[
+ --pipe
+ --organization=Homebrew
+ --manual=brew
+ #{source_file}
+ ]
+ page = File.basename(source_file, ".md")
+
+ target_html = DOC_PATH/"#{page}.html"
+ target_html.atomic_write Utils.popen_read("ronn", "--fragment", *args)
+
+ target_man = TARGET_PATH/page
+ target_man.atomic_write Utils.popen_read("ronn", "--roff", *args)
end
end
end