From b1b4518998701dc9c0afa7c2a430c14fc40e5493 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 19 Dec 2020 19:30:33 +0100 Subject: [PATCH] Fix `sudo` prompt. --- Library/Homebrew/system_command.rb | 4 ++-- Library/Homebrew/test/system_command_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/system_command.rb b/Library/Homebrew/system_command.rb index 8436376fd9..fdec24fb93 100644 --- a/Library/Homebrew/system_command.rb +++ b/Library/Homebrew/system_command.rb @@ -158,7 +158,7 @@ class SystemCommand options = { # Create a new process group so that we can send `SIGINT` from # parent to child rather than the child receiving `SIGINT` directly. - pgroup: true, + pgroup: sudo? ? nil : true, } options[:chdir] = chdir if chdir @@ -174,7 +174,7 @@ class SystemCommand @status = raw_wait_thr.value rescue Interrupt - Process.kill("INT", pid) if pid + Process.kill("INT", pid) if pid && !sudo? raise Interrupt rescue SystemCallError => e @status = $CHILD_STATUS diff --git a/Library/Homebrew/test/system_command_spec.rb b/Library/Homebrew/test/system_command_spec.rb index 0ade6a87c6..b1da8157f0 100644 --- a/Library/Homebrew/test/system_command_spec.rb +++ b/Library/Homebrew/test/system_command_spec.rb @@ -55,7 +55,7 @@ describe SystemCommand do .to receive(:popen3) .with( an_instance_of(Hash), ["/usr/bin/sudo", "/usr/bin/sudo"], "-E", "--", - "/usr/bin/env", "A=1", "B=2", "C=3", "env", *env_args, pgroup: true + "/usr/bin/env", "A=1", "B=2", "C=3", "env", *env_args, pgroup: nil ) .and_wrap_original do |original_popen3, *_, &block| original_popen3.call("true", &block)