Reputation: 8367
please consider the following:
$ cd ~/.emacs.d/lisp/tabbar
$ git pull
Already up-to-date.
$ git pull | grep -q "Already" ; echo $?
0
Still with me? Now:
$ cd ~/src/emacs-tmp/trunk
$ bzr up
Tree is up to date at revision 108837 of branch /home/px/src/emacs-tmp/trunk
$ bzr up | grep -q "Tree" ; echo $?
Tree is up to date at revision 108837 of branch /home/px/src/emacs-tmp/trunk
1
Questions :
Upvotes: 0
Views: 279
Reputation: 12496
Probably because in the first case the output is on stdout, and in the second case its on stderr. You can add a "2>&1" to the commands to throw everything to stadout.
Because you said "-q", which tells grep to shut up :-)
Upvotes: 1
Reputation: 1433
Looks like bzr is outputting to the standard error device (/dev/stderr
), while grep
is only inspecting the standard input. You can confirm or deny this guess by trying to redirect stderr
to stdin
:
bzr up 2>&1 | grep -q "Tree" ; echo $?
Upvotes: 1
Reputation: 57408
I think that your "visible" command is output'ting to stderr, not stdout. grep only looks in stdout, unless you redirect with 2>&1.
Therefore, try
bzr up 2>&1 | grep -q "Tree" ; echo $?
Upvotes: 1