Cannot get why
$ apt-cache policy foo
N: Unable to locate package foo
but
$ apt-cache policy foo 2>&1 | grep .
is empty.
Where in the latter call am I doing the wrong assumption?
The original task: I need to process the apt-cache policy
output presumably :-)
UPD:
foo
used in my example may be substituted with any package name that does not exist in your apt-get
index.
UPD 2:
there is an answer with a workaround. Additional +50
bounty will be awarded to anyone who explains why the 2>&1
solution does not work.
# apt-cache policy vim 2>&1 |grep . vim: Installed: 2:7.4.712-2 Candidate: 2:7.4.712-2 Version table: *** 2:7.4.712-2 0 500 http://ftp.debian.org/debian/ sid/main amd64 Packages 100 /var/lib/dpkg/status
strace apt-cache policy foo 2>&1
and there is a system callioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
I think because of this call 1(stdout) has problems. I mean it is not written to tty anymore