Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass TTY width to Open3. #15255

Merged
merged 1 commit into from Apr 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions Library/Homebrew/system_command.rb
Expand Up @@ -197,10 +197,13 @@ def each_output_line(&block)
}
options[:chdir] = chdir if chdir

pid = T.let(nil, T.nilable(Integer))
raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = ignore_interrupts do
Open3.popen3(env, [executable, executable], *args, **options)
.tap { |*, wait_thr| pid = wait_thr.pid }
Open3.popen3(
env.merge({ "COLUMNS" => Tty.width.to_s }),
[executable, executable],
*args,
**options,
)
end

write_input_to(raw_stdin)
Expand Down Expand Up @@ -228,7 +231,7 @@ def each_output_line(&block)
thread_done_queue << true
line_thread.join
rescue Interrupt
Process.kill("INT", pid) if pid && !sudo?
Process.kill("INT", raw_wait_thr.pid) if raw_wait_thr && !sudo?
raise Interrupt
rescue SystemCallError => e
@status = $CHILD_STATUS
Expand Down