bin/rb

Tue, 21 Apr 2020 22:01:03 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Tue, 21 Apr 2020 22:01:03 -0500
changeset 856
d74ad38b2ca4
parent 719
490da8798a6a
permissions
-rwxr-xr-x

Move omni back up 1

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

mercurial