maillog: 11/08/2005-21:06:34(-0700): Donnie Berkholz types
> Georgi Georgiev wrote:
> |   As you can see, it's the "static" in the end of the line. Maybe you
> |   should grep for "-static" instead.
> 
> | - To avoid eventual problems with similarly named libraries (libpam and
> |   libpam_misc for example; grepping for -lpam would also match
> |   -lpam_misc) you could grep for "\<-l${libname}\>" instead. This would
> |   also solve the space-or-tab problem.
> 
> Try this one. It should address both issues.

I should have tested a bit more.

[EMAIL PROTECTED] ~ $ echo 'a -lbcd' | grep -- '-l'
a -lbcd
[EMAIL PROTECTED] ~ $ echo 'a -lbcd' | grep -- '\b-l'
[EMAIL PROTECTED] ~ $ echo 'a lbcd'  | grep -- '\bl'
a lbcd

It's the "-" that is not a part of a word. Any ideas? I guess the "\b"
after ${libname} is fine, but the one before the "-" is not. It's down
to [[:space:]]-l${libname}\b it seems. And hopefully there won't be any
any lines starting with "-l", or any "-llib" being quoted which is legal
but unmatchable. Ah, cannot grep be told that "-" is a valid "word"
symbol.

The only reason the script currently works is because:

grep '\b-l[[:alnum:]].*\b' ${1}

matches the "-l" in x86_64-pc-linux-gnu-gcc

You also do not need the ".*\b" in the above. The ".*\b" would always
match until the last word on the line (grep doesn't do greedy wildcard
matching), and since it would *always* match, there is no need in
matching at all.

-- 
\    Georgi Georgiev   \  Try the Moo Shu Pork. It is especially       \
 /    [EMAIL PROTECTED]     / good today.                                   /
\   +81(90)2877-8845   \                                               \

Attachment: pgpgJCbFpja2U.pgp
Description: PGP signature

Reply via email to