0

In an irb console these lines execute as I expect:

require 'open3'
stdout, stderr, exit_status = Open3.capture3('clang-format < tmp')
puts stdout
puts stderr
puts exit_status

That is, the output of command clang-format < tmp is printed out through stdout; for stderr the value is nil and for exit_status the output is pid 28181 exit 0.

However, when I execute them in a script the output for stdoutis empty, but the value of exit_status is printed out.

Why that? Could someone please illuminate me?

lrleon
  • 2,610
  • 3
  • 25
  • 38
  • What do stderr and exit_status print? – shortwavedave Aug 28 '16 at 18:30
  • I tried the same thing and got the expected result. Make sure the tmp file that clang-format is referencing inside the script is the same tmp file referenced from irb. That's the only thing I could think of, you have a duplicate tmp file somewhere that is empty – shortwavedave Aug 28 '16 at 18:54
  • 1
    http://stackoverflow.com/questions/690151/getting-output-of-system-calls-in-ruby i think this is what you are looking for. – Muaaz Rafi Aug 28 '16 at 20:41

0 Answers0