718:30888d15e6ee | 719:490da8798a6a |
---|---|
1 #!/usr/bin/env ruby | |
2 File.join(Dir.home, '.rbrc').tap { |f| load f if File.exists?(f) } | |
3 | |
4 def execute(_, code) | |
5 puts _.instance_eval(&code) | |
6 rescue Errno::EPIPE | |
7 exit | |
8 end | |
9 | |
10 single_line = ARGV.delete('-l') | |
11 code = eval("Proc.new { #{ARGV.join(' ')} }") | |
12 single_line ? STDIN.each { |l| execute(l.chomp, code) } : execute(STDIN.each_line, code) | |
13 | |
14 # https://raw.githubusercontent.com/thisredone/rb/master/rb |