Skip to content

Commit

Permalink
Stream output while shelling out to bash
Browse files Browse the repository at this point in the history
When a command takes a long time we need visibility into what's happening. This change prints anything to stdout that is being executed by rundoc.

Close #30
  • Loading branch information
schneems committed Jul 9, 2024
1 parent 75fc038 commit ea36656
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## HEAD


- Fix: Bash commands now stream their outputs while they're running (https://github.com/zombocom/rundoc/pull/57)
- Change: Minimum selenium-webdriver is now 4.x. (https://github.com/zombocom/rundoc/pull/41)

## 2.0.1
Expand Down
9 changes: 8 additions & 1 deletion lib/rundoc/code_command/bash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@ def shell(cmd, stdin = nil)
IO.popen(cmd, "w+") do |io|
io << stdin if stdin
io.close_write
result = sanitize_escape_chars io.read

until io.eof?
buffer = io.gets
puts " #{buffer}"

result << sanitize_escape_chars(buffer)
end
end

unless $?.success?
raise "Command `#{@line}` exited with non zero status: #{result}" unless keyword.to_s.include?("fail")
end
Expand Down

0 comments on commit ea36656

Please sign in to comment.