<commit_before>#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-

# brew-which-formula: prints the formula which provides the given binary
#
# Usage:
#
#   brew which <command> [<command> ...]
#
#

require "shellwords"

# brew
require "extend/ARGV.rb"

LIST_PATH = File.expand_path("#{File.dirname(__FILE__)}/../executables.txt")

def matches(cmd)
  # We use 'grep' here not to read the whole file
  `grep #{Shellwords.escape cmd} #{LIST_PATH} 2>/dev/null`.chomp.split(/\n/)
end

def which_formula(cmd)
  cmd = cmd.downcase

  (matches cmd).each do |m|
    formula, cmds = m.split(":", 2)
    puts formula if !formula.nil? && !cmds.nil? && cmds.include?(cmd)<commit_msg>grep only the first match<commit_after>#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-

# brew-which-formula: prints the formula which provides the given binary
#
# Usage:
#
#   brew which <command> [<command> ...]
#
#

require "shellwords"

# brew
require "extend/ARGV.rb"

LIST_PATH = File.expand_path("#{File.dirname(__FILE__)}/../executables.txt")

def matches(cmd)
  # We use 'grep' here not to read the whole file
  `grep -m 1 #{Shellwords.escape cmd} #{LIST_PATH} 2>/dev/null`.chomp.split(/\n/)
end

def which_formula(cmd)
  cmd = cmd.downcase

  (matches cmd).each do |m|
    formula, cmds = m.split(":", 2)
    puts formula if !formula.nil? && !cmds.nil? && cmds.include?(cmd)
{'fraction_non_alphanumeric': 0.1744617668893838, 'fraction_numerical': 0.005196733481811433, 'mean_word_length': 3.6805555555555554, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1042001', 'n_tokens_mistral': 508, 'n_tokens_neox': 493, 'n_words': 129}