Bug#746434: apt: new apt breaks a shell script by reading from standard input when it shouldn't
On Tue, Apr 29, 2014 at 10:40:52PM +0000, Gianluca Borello wrote:
> Package: apt
> Version: 1.0.2
> Severity: normal
Thanks for your bugeport.
> I have an automated installation script that doesn't work anymore on Sid. This is a snippet of code:
>
> #!/bin/bash
>
> apt-get -qq -y install iftop
> neverexecuted
>
> If executed by piping it to bash, the very first time (when the package is not installed), I get:
[..]
I can reproduce this and bisected it to commit 872816. The attached
diff fixes it for me, would be great if you could confirm.
Cheers,
Michael
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 959d064..bc86258 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1239,9 +1239,9 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// if tcgetattr does not return zero there was a error
// and we do not do any pty magic
_error->PushToStack();
- if (tcgetattr(STDOUT_FILENO, &tt) == 0)
+ if (tcgetattr(STDIN_FILENO, &tt) == 0)
{
- ioctl(0, TIOCGWINSZ, (char *)&win);
+ ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&win);
if (openpty(&master, &slave, NULL, &tt, &win) < 0)
{
_error->Errno("openpty", _("Can not write log (%s)"), _("Is /dev/pts mounted?"));
Reply to: