gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Gnu-arch-users] Re: fedora core 2 will include subversion (a nd not


From: Parker, Ron
Subject: RE: [Gnu-arch-users] Re: fedora core 2 will include subversion (a nd not gnu arch)
Date: Fri, 27 Feb 2004 09:24:51 -0600

> From: Brian May [mailto:address@hidden
> Sent: Thursday, February 26, 2004 4:38 PM

> >>>>> "Colin" == Colin Walters <address@hidden> writes:
> 
>     Colin> #!/bin/sh
>     Colin> for log in $(tla logs); do
>     Colin> if tla cat-log | grep "$1" 1>/dev/null; then
>     Colin> echo $log
>     Colin> fi
>     Colin> done

> Also, if given a parameter of "xyz.c", I think the above would match
> entries with "abcxyc.c", "xyzbc" both in the *-files headers as well
> as the summary.

Well, grep needs to be fgrep and using -w allows us to match entire file
names (by requiring a match to go to word boundaries) even with special
characters, spaces, dollar signs, etc., in them.


Using "grep -w" alone is insufficient:

        $ FN='a $100.'
        $ echo -e 'Mary had a $100.\nMary had a $1000.'|grep -w "$FN"
        Mary had a $100.
        Mary had a $1000.

It really does need to be fgrep:
        $ FN='a $100.'
        $ echo -e 'Mary had a $100.\nMary had a $1000.'|fgrep -w "$FN"
        Mary had a $100.

This does still however have the failing of missing on dotfiles vs.
non-dotfiles.

        $ FN='10 dollars'
        $ echo -e 'Mary had .10 dollars.\nMary had 10 dollars.'|fgrep -w
"$FN"
        Mary had .10 dollars.
        Mary had 10 dollars.

Actually I suppose the failing is not restricted to dotfiles, but is more
generally that a file name which may be decomposed into multiple words will
be matched by any word subset if its name.  This applies to files with most
punctuation in them, including the ubiquitous ".", and files with whitespace
in their names.  I am not sure there is a good general solution to this
problem.  There do not appear to be delimiters in the cat-log output that
may be looked for on either side of the file name.  This one little issue
could be addressed if there were an option for cat-log that spit out one
filename per line, but since cat-log is just that a catting of the log file
in the archive, this is not really possible either.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]