Sha256: 800ff9ad824f50d0d6cda97bada74f3fe3f8216b0e740d5f4d99dd8fac10811f

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 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
  data = eval code
rescue Exception
  puts "#:rbbt_exec Error"
  puts $!.message
  puts $!.backtrace * "\n"
  exit(-1)
end

data = data.to_s(:sort, true) 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)
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbbt-util-4.4.0 bin/rbbt_exec.rb