sample/less.rb


DEFINITIONS

This source file includes following functions.


   1  #! /usr/local/bin/ruby
   2  
   3  ZCAT = "/usr/local/bin/zcat"
   4  LESS = "/usr/local/bin/less"
   5  
   6  FILE = ARGV.pop
   7  OPTION = (if ARGV.length == 0; "" else ARGV.join(" "); end)
   8  
   9  if FILE =~ /\.(Z|gz)$/
  10    exec(format("%s %s | %s %s", ZCAT, FILE, LESS, OPTION))
  11  elsif FILE == nil
  12    exec(format("%s %s", LESS, OPTION))
  13  else
  14    print(format("%s %s %s", LESS, OPTION, FILE), "\n")
  15    exec(format("%s %s %s", LESS, OPTION, FILE))
  16  end
  17  exit()