lib/pre-commit/checks/grep.rb in pre-commit-0.38.0 vs lib/pre-commit/checks/grep.rb in pre-commit-0.38.1
- old
+ new
@@ -91,14 +91,15 @@
%w{grep -PnIH}
end
end
def detect_grep_version
- first_line = Open3.popen2('grep', '--version') do |_, stdout, _|
- stdout.readline
- end
+ Open3.popen3('grep', '--version') do |_, stdout, _|
+ return '' if stdout.eof?
- first_line.sub(/^[^0-9.]*\([0-9.]*\)$/, '\1')
+ first_line = stdout.readline
+ return first_line.sub(/^[^0-9.]*\([0-9.]*\)$/, '\1')
+ end
end
def extra_execute(files)
return nil if extra_pattern.nil? or extra_pattern.empty?
args = grep + [extra_pattern] + files