Sha256: 648661831b4b782c3fdde0bb1048ce21b0313c7aeb9c72c5cc8dcf1d7ffab12d

Contents?: true

Size: 564 Bytes

Versions: 108

Compression:

Stored size: 564 Bytes

Contents

require "open3"

module J1
  module Utils
    module Exec1
      extend self

      # Runs a program in a sub-shell.
      #
      # *args - a list of strings containing the program name and arguments
      #
      # Returns a Process::Status and a String of output in an array in
      # that order.
      def run(*args)
        stdin, stdout, stderr, process = Open3.popen3(*args)
        out = stdout.read.strip
        err = stderr.read.strip

        [stdin, stdout, stderr].each(&:close)
        [process.value, out + ';' + err]
      end

    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
j1-template-2024.3.17 lib/j1/utils/exec1.rb
j1-template-2024.3.16 lib/j1/utils/exec1.rb
j1-template-2024.3.15 lib/j1/utils/exec1.rb
j1-template-2024.3.14 lib/j1/utils/exec1.rb
j1-template-2024.3.13 lib/j1/utils/exec1.rb
j1-template-2024.3.12 lib/j1/utils/exec1.rb
j1-template-2024.2.1 lib/j1/utils/exec1.rb
j1-template-2024.2.0 lib/j1/utils/exec1.rb
j1-template-2024.1.5 lib/j1/utils/exec1.rb
j1-template-2024.1.4 lib/j1/utils/exec1.rb
j1-template-2024.1.3 lib/j1/utils/exec1.rb
j1-template-2024.1.2 lib/j1/utils/exec1.rb
j1-template-2024.1.1 lib/j1/utils/exec1.rb
j1-template-2024.1.0 lib/j1/utils/exec1.rb
j1-template-2024.0.3 lib/j1/utils/exec1.rb
j1-template-2024.0.2 lib/j1/utils/exec1.rb
j1-template-2024.0.1 lib/j1/utils/exec1.rb
j1-template-2024.0.0 lib/j1/utils/exec1.rb
j1-template-2023.10.2 lib/j1/utils/exec1.rb
j1-template-2023.10.1 lib/j1/utils/exec1.rb