diff options
Diffstat (limited to 'common/bin/rb')
-rwxr-xr-x | common/bin/rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/bin/rb b/common/bin/rb new file mode 100755 index 0000000..980016b --- /dev/null +++ b/common/bin/rb @@ -0,0 +1,14 @@ +#!/usr/bin/ruby +# Taken from https://github.com/thisredone/rb + +File.join(Dir.home, '.rbrc').tap { |f| load f if File.exist?(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) |