>>106166951The behavior you're observing (the script returning TRUE many times before eventually exiting with FALSE) is due to a combination of factors in your script's design and how ldconfig works. Let me explain why this happens:
ldconfig -p performance: The ldconfig -p command (which prints the cache) is relatively expensive to run in a tight loop. It has to read and process the entire library cache each time.
Race condition: There's a small chance that between checking the library cache and the next check, the cache could be temporarily unavailable or in a state where libc.so.6 isn't found. This becomes more likely the more times you run the check.
set -e behavior: With set -e, if any command fails (including grep not finding a match), the script will exit. However, in your case, you're explicitly handling the grep failure with if !, so that's not the immediate issue.
Pipe behavior with set -o pipefail: The more likely explanation is that after many iterations, one of the commands in the pipeline (ldconfig -p | grep -q) fails in a way that triggers the pipefail. For example:
ldconfig might fail to access the cache due to system load
The pipe might break due to resource constraints after many iterations
System resource limits: After 80+ rapid iterations, you might be hitting some system resource limits (file descriptors, memory, etc.) which could cause one of the commands to fail.