Sha256: 769e1d89c04d4dfeffc6e6e40693bc2fb31db13b77957f9364891dfaba800f4c

Contents?: true

Size: 765 Bytes

Versions: 264

Compression:

Stored size: 765 Bytes

Contents

#!/usr/bin/env ruby

code_file = ARGV[0]
output = ARGV[1]

require 'rbbt-util'

code = case 
       when (code_file.nil? or code_file == '-')
         STDIN.read
       else
         Open.read(code_file)
       end

begin
  if code_file.nil?
    data = instance_eval code
  else
    data = instance_eval code, code_file
  end
rescue Exception
  puts "#:rbbt_exec Error"
  puts $!.message
  puts $!.backtrace * "\n"
  exit(-1)
end

#data = data.to_s(:sort) if TSV === data
data = data * "\n" if Array === data

case
when (output.nil? or output == '-')
  puts data
when output == "file"
  if Misc.filename? data
    tmpfile = data
  else
    tmpfile = TmpFile.tmp_file
    Open.write(tmpfile, data.to_s)
  end

  puts tmpfile
else
  Open.write(output, data.to_s)
end

Version data entries

264 entries across 264 versions & 1 rubygems

Version Path
rbbt-util-5.43.0 bin/rbbt_exec.rb
rbbt-util-5.42.0 bin/rbbt_exec.rb
rbbt-util-5.41.1 bin/rbbt_exec.rb
rbbt-util-5.41.0 bin/rbbt_exec.rb
rbbt-util-5.40.5 bin/rbbt_exec.rb
rbbt-util-5.40.4 bin/rbbt_exec.rb
rbbt-util-5.40.3 bin/rbbt_exec.rb
rbbt-util-5.40.0 bin/rbbt_exec.rb
rbbt-util-5.39.0 bin/rbbt_exec.rb
rbbt-util-5.38.1 bin/rbbt_exec.rb
rbbt-util-5.38.0 bin/rbbt_exec.rb
rbbt-util-5.37.16 bin/rbbt_exec.rb
rbbt-util-5.37.15 bin/rbbt_exec.rb
rbbt-util-5.37.14 bin/rbbt_exec.rb
rbbt-util-5.37.13 bin/rbbt_exec.rb
rbbt-util-5.37.12 bin/rbbt_exec.rb
rbbt-util-5.37.11 bin/rbbt_exec.rb
rbbt-util-5.37.10 bin/rbbt_exec.rb
rbbt-util-5.37.9 bin/rbbt_exec.rb
rbbt-util-5.37.8 bin/rbbt_exec.rb