![](https://secure.gravatar.com/avatar/a0f6b595b0e3b7f3abba19eeb8261fc2.jpg?s=120&d=mm&r=g)
A few notes: a.) On some platforms fgrep has been deprecated (in favour of `grep -F`) so it's not future-proof
I don’t think the aliases fgrep and egrep have ever been supposed to be portable. POSIX has grep -F and grep -E, and that’s what we should use.
b.) The caret (^) passed to `grep -F` will not be interpreted as a regex, since -F forces non-regexp, meaning the '^' will be interpreted literally (and the string "^musl" is not in the ldd output).
The caret in itself was not the problem, only that it was not escaped for the shell. Testing a regexp, with -E of course, is just as robust, and allows us to be more specific about what we test.
if command -v ldd >/dev/null && ldd --version 2>&1 | grep -Fq 'musl' > /dev/null
grep -E '^musl' works just as well; and as I explained, -q may return 0 even if there are errors, so should be avoided. Best, Arthur