Sha256: a75932c8f2b39efd8ca4a195230d99b1cf2894f22ec7ab112b9b158cf262c0c9

Contents?: true

Size: 625 Bytes

Versions: 4

Compression:

Stored size: 625 Bytes

Contents

module Pmux
  module FixCmdLine
    def fix_cmd_line cmd_line, in_path=nil, out_path=nil, err_path=nil, tmp_dir=nil
      res = []
      cmds = cmd_line.split /\s*\|\s*/
      n = 0
      for cmd in cmds
        c, = cmd.split
        if tmp_dir and File.executable?(cc = "#{tmp_dir}/#{c}")
          #cmd = cc
          cmd = "#{tmp_dir}/#{cmd}"
        end
        if n == 0
          cmd << " #{in_path}" if in_path
          err_path ||= '/dev/null'
          cmd << " 2>#{err_path}"
        end
        res.push cmd
        n += 1
      end
      cmd << " >>#{out_path}" if out_path
      res.join '|'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pmux-0.1.3 lib/pmux/fixcmd.rb
pmux-0.1.2 lib/pmux/fixcmd.rb
pmux-0.1.1 lib/pmux/fixcmd.rb
pmux-0.1.0 lib/pmux/fixcmd.rb