Subject: bug#34367: GNU sed v. 4.5 – Are printed the very rows aimed not to be printed.

From: Assaf Gordon <[email-masked]>
Date: Thu, 7 Feb 2019 15:27:57 -0700

tags 34367 notabug
close 34367
stop

Hello,

On 2019-02-07 4:06 a.m., Ricky Tigg wrote:
> # fsck /dev/sdc | sed '1,2d'
> e2fsck 1.44.3 (10-July-2018)
> e2fsck: need terminal for interactive repairs:
> 
> Are printed the very rows aimed not to be printed; then *Sed* behaved
> according to command sed '1,2!d'.
> 

"fsck" prints these lines to STDERR, which is not piped to sed,
hence they are printed.

Observe:

   $ /sbin/fsck.ext3 foo > /dev/null
   e2fsck 1.43.4 (31-Jan-2017)
   e2fsck: need terminal for interactive repairs

versus:

   $ /sbin/fsck.ext3 foo 2> /dev/null
   foo: clean, 11/128 files, 38/1024 blocks

Also,
Notice "fsck" warns you that STDOUT is not a terminal
(because of piping to sed), and that would lead to
weird/unexpected output in interactive mode.

regards,
  - assaf