Bug#927992: Write errors and warnings to STDERR, don't hide them if not a tty

2019-04-26 Thread 積丹尼 Dan Jacobson
> "JAK" == Julian Andres Klode  writes:
JAK> Enabling that for non-interactive users can break stuff, so I'm not sure 
we want to change this.

Well at least have a /etc/apt/apt.conf.d variable we can set to send
them to STDERR instead of nowhere. That way if we break something it
would be our own fault, not yours. Thanks.



Bug#927992: Write errors and warnings to STDERR, don't hide them if not a tty

2019-04-26 Thread Julian Andres Klode
On Fri, Apr 26, 2019 at 11:02:42AM +0800, 積丹尼 Dan Jacobson wrote:
> Package: apt
> Version: 1.8.0
> File: /usr/bin/apt-cache
> 
> In Unix/Linux we have STDOUT and STDERR. Please just use these two,
> and don't invent "smarter ways."
> 
> Really really bad and this will come back to bite you one day:
> 
> You have a kind of message that is only shown if the user is on a tty.
> 
> You don't user the industry standard of sending it to STDERR,
> You instead just hide it... if the user apparently isn't using a TTY.
> 
> One can't even pipe the output of your program to any other program,
> expecting messages to go to STDERR. The message just disappears!
> 
> $ apt-cache show twitter-bootstrap
> N: Can't select candidate version from package twitter-bootstrap as it has no 
> candidate
> N: Can't select versions from package 'twitter-bootstrap' as it is purely 
> virtual
> N: No packages found
> $ apt-cache show twitter-bootstrap 2>&1|wc
>   0   0   0
> 
> In fact I can think of no other program in the entire history of Unix
> that has decided to do that.

A lot of programs do that, mostly for progress reporting. APT also lowers the
level of errors shown from WARNING to DEBUG when running interactively; 
effectively,
running non-interactively is the same as passing -q - just consider them 
progress
reports - they are not relevant to the function of the program.

These messages have not been shown at all until 2010, and then we enabled them 
for
interactive users in 65beb5720f82845bf175e0cd80f070da21838827. Enabling that for
non-interactive users can break stuff, so I'm not sure we want to change this.


-- 
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer  i speak de, en



Bug#927992: Write errors and warnings to STDERR, don't hide them if not a tty

2019-04-25 Thread 積丹尼 Dan Jacobson
Package: apt
Version: 1.8.0
File: /usr/bin/apt-cache

In Unix/Linux we have STDOUT and STDERR. Please just use these two,
and don't invent "smarter ways."

Really really bad and this will come back to bite you one day:

You have a kind of message that is only shown if the user is on a tty.

You don't user the industry standard of sending it to STDERR,
You instead just hide it... if the user apparently isn't using a TTY.

One can't even pipe the output of your program to any other program,
expecting messages to go to STDERR. The message just disappears!

$ apt-cache show twitter-bootstrap
N: Can't select candidate version from package twitter-bootstrap as it has no 
candidate
N: Can't select versions from package 'twitter-bootstrap' as it is purely 
virtual
N: No packages found
$ apt-cache show twitter-bootstrap 2>&1|wc
  0   0   0

In fact I can think of no other program in the entire history of Unix
that has decided to do that.

If the user doesn't want the message he can just do 2> /dev/null. Or
2>&- . That's how we do things on Linux/Unix.

$ apt show twitter-bootstrap
Package: twitter-bootstrap
State: not a real package (virtual)
N: Can't select candidate version from package twitter-bootstrap as it has no 
candidate
N: Can't select versions from package 'twitter-bootstrap' as it is purely 
virtual
N: No packages found

Now experimenting with apt,

$ apt show twitter-bootstrap 2>&1 | nl -b a
 1
 2  WARNING: apt does not have a stable CLI interface. Use with caution in 
scripts.
 3
 4  Package: twitter-bootstrap
 5  State: not a real package (virtual)
$ apt show twitter-bootstrap | nl -b a

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

 1  Package: twitter-bootstrap
 2  State: not a real package (virtual)

Aptitude is much more consistent,

$ aptitude show twitter-bootstrap | nl -b a
 1  Package: twitter-bootstrap
 2  State: not a real package
 3  Provided by: libjs-twitter-bootstrap (2.0.2+dfsg-10)
$ aptitude show twitter-bootstrap
Package: twitter-bootstrap
State: not a real package
Provided by: libjs-twitter-bootstrap (2.0.2+dfsg-10)

Anyway your idea of a tty is fine for you. But not for how many users
will use these programs. Thanks.