> 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.
Either is fine I am sure, but from a code maintenance and testing perspective I'd be more concerned about a regression or misinterpretation to an unescaped carat that breaks the detection on zsh (and perhaps elsewhere), as opposed to anticipating a hypothetical new or different standard C library that needs detection for an alternative build. > grep -E '^musl' works just as well; and as I explained, -q may return 0 even if there are errors, so should be avoided. The -q is superfluous with the >/dev/null, and should be removed; incidentally though, is it not harmless in this case? Avoiding it is probably good measure for the reason mentioned (i.e. error on directories), but I'm not sure that such an error in grep is possible when piped from ldd, is it? I'm curious when such could occur. Cheers, Brian On Mon, 9 Apr 2018 at 15:35 Arthur Reutenauer < arthur.reutena...@normalesup.org> wrote: > > 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 > > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to > the Wiki! > > maillist : email@example.com / > http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > > ___________________________________________________________________________________ -- *from the personal account of:* *Brian M Hunt *<brianmh...@gmail.com> Direct: +1-289-684-4677 LinkedIn: https://linkedin.com/in/brianmhunt *This e-mail may contain information that is private, privileged, confidential and/or exempt from disclosure. Except as per this notice no waiver of any kind is intended by sending this e-mail, and this email is intended only for the named recipient(s) or the subscribers of a forwarding service the email is sent directly to and to which service you are an authorized recipient. Use, dissemination or copying without authorization is prohibited. Please notify the sender and destroy all copies of this e-mail if you have received this email in error.*
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : firstname.lastname@example.org / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________