mirror of https://tildegit.org/ben/dotfiles
13 lines
272 B
Ruby
Executable File
13 lines
272 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
def execute(_, code)
|
|
puts _.instance_eval(&code)
|
|
rescue Errno::EPIPE
|
|
exit
|
|
end
|
|
|
|
single_line = ARGV.delete('-l')
|
|
code = eval("Proc.new { #{ARGV.join(' ')} }")
|
|
single_line ? STDIN.each { |l| execute(l.chomp, code) } : execute(STDIN.each_line, code)
|
|
|