Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix cheat hanging if the pager is quit before consuming all input
An easy test of this is with `cheat iana_port_list`.
If less is quit immediately, cheat will hang forever due to the improperly closed pipe.
But when the pipe is closed properly, it will get an Errno::EPIPE instead, so we have
to handle both conditions.
  • Loading branch information
lilyball committed Mar 19, 2008
1 parent 06d0679 commit b35f228
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/cheat.rb
Expand Up @@ -94,6 +94,8 @@ def show(sheet_yaml)
run_pager
puts sheet.first + ':'
puts ' ' + sheet.last.gsub("\r",'').gsub("\n", "\n ").wrap
rescue Errno::EPIPE
# do nothing
rescue
puts "That didn't work. Maybe try `$ cheat cheat' for help?" # Fix Emacs ruby-mode highlighting bug: `"
end
Expand Down Expand Up @@ -174,6 +176,8 @@ def run_pager
unless Kernel.fork # Child process
STDOUT.reopen(write)
STDERR.reopen(write)
read.close
write.close
return
end

Expand Down

0 comments on commit b35f228

Please sign in to comment.