I have some SLES 12 SP5 machines with grep version 2.16 and on a single machine I'm heavily using scripts which contained the following `grep --quiet` condition:

 # $pid_list contains the result of pstree and $script_pid equals $$
 if echo "$pid_list" | grep -qF "($script_pid)"; then
 continue
 fi
 if echo "$pid_list" | grep -qF "($script_pid)"; then
 echo "Error: grep has a bug!"
 continue
 fi

I doubled it, because by a chance of ~0.1% the first condition failed, while the second identical condition succeeded?!

After changing the condition as follows, it works flawlessly (Full code [here][1]):

 if echo "$pid_list" | grep -F "($script_pid)" >/dev/null; then
 continue
 fi

Regarding the manual the `quiet` option should behave as I would expect it. It should even return true if an error happens:

> Exit immediately with zero status if any match is found, even if an error was detected

So I'm confused why it fails sometimes. RAM and filesystem of the machine is fine. The grep binary has the correct file hash, too.

I [searched for a commit][2], but the only one I found is [from 2001][3], which should be part of [2.16 as it is from 2014][4].


 [1]: https://unix.stackexchange.com/questions/741848/why-does-pgrep-return-randomly-a-wrong-pid
 [2]: http://git.savannah.gnu.org/gitweb/?p=grep.git&a=search&h=HEAD&st=commit&s=-q
 [3]: http://git.savannah.gnu.org/gitweb/?p=grep.git;a=commit;h=66db7a353fdcc432905f1e8bc97a6a4cf8d06dff
 [4]: https://savannah.gnu.org/news/?id=7800