-
-
Save samueldr/43f3c24b49b3b447c6611c06dec0f94a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "open3" | |
require "pp" | |
name = ARGV.shift | |
search = "^/bin/#{name}$" | |
cmd = ["nix-locate", "-1wr", search] | |
stdin, stdout, stderr, wait_thr = Open3.popen3(*cmd) | |
out = (stdout.gets(nil) or "").split("\n") | |
stdout.close | |
attrs = out | |
.select { |s| s[0] != "(" } | |
.map{ |s| s.sub(/\.out$/, "") } | |
.sort | |
STDERR.puts "#{name}: command not found" | |
if out.length.positive? then | |
STDERR.puts "" | |
STDERR.puts " → #{name} is provided by:" | |
attrs.each do |attr| | |
STDERR.puts " * #{attr}" | |
end | |
end | |
exit 127 | |
# vim: ft=ruby |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment