add bin/rb, from https://github.com/thisredone/rb

Tue, 28 Aug 2018 18:09:17 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Tue, 28 Aug 2018 18:09:17 -0500
changeset 719
490da8798a6a
parent 718
30888d15e6ee
child 720
adc91288d03c

add bin/rb, from https://github.com/thisredone/rb

bin/rb file | annotate | diff | comparison | revisions
new file mode 100755
--- /dev/null
+++ b/bin/rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+File.join(Dir.home, '.rbrc').tap { |f| load f if File.exists?(f) }
+
+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)
+
+# https://raw.githubusercontent.com/thisredone/rb/master/rb

mercurial