summaryrefslogtreecommitdiff
path: root/tool/leaked-globals
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-02-01 21:20:42 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-02-02 10:42:53 +0900
commitc0629a055ada4efcd6f520a8ff6f6d4d71e878a0 (patch)
treee9442fa04a96e1c97bd45692658d0c5903388ba8 /tool/leaked-globals
parentf22bec79fed582f10e1791c421ebc760121b8878 (diff)
Prefer `IO.popen` over `IO.foreach` with `|`
Diffstat (limited to 'tool/leaked-globals')
-rwxr-xr-xtool/leaked-globals11
1 files changed, 9 insertions, 2 deletions
diff --git a/tool/leaked-globals b/tool/leaked-globals
index 3e3bda5632..b80ae39073 100755
--- a/tool/leaked-globals
+++ b/tool/leaked-globals
@@ -1,12 +1,13 @@
#!/usr/bin/ruby
require_relative 'lib/colorize'
+require 'shellwords'
until ARGV.empty?
case ARGV[0]
when /\A SYMBOL_PREFIX=(.*)/x
SYMBOL_PREFIX = $1
when /\A NM=(.*)/x # may be multiple words
- NM = $1
+ NM = $1.shellsplit
when /\A PLATFORM=(.+)?/x
platform = $1
when /\A SOEXT=(.+)?/x
@@ -69,7 +70,13 @@ if soext
so = soext =~ ARGV.first
end
end
-IO.foreach("|#{NM} #{ARGV.join(' ')}") do |line|
+
+Pipe = Struct.new(:command) do
+ def open(&block) IO.popen(command, &block) end
+ def each(&block) open {|f| f.each(&block)} end
+end
+
+Pipe.new(NM + ARGV).each do |line|
line.chomp!
next so = nil if line.empty?
if so.nil? and line.chomp!(":")