Re: [GUILT PATCH 1/4] get_series: Remove comments from end of series lines
- From
- Josef Sipek <jsipek@fsl.cs.sunysb.edu>
- Date
- Jul 30, 2007, 05:26 UTC
- Message-ID
- <20070730052633.GI22017@filer.fsl.cs.sunysb.edu>
- In-Reply-To
- <87r6mqcvzp.fsf@hubert.paunchy.net>
On Sun, Jul 29, 2007 at 10:15:54PM -0700, Eric Lesh wrote:
> > [ Do you mind if these messages go to both your email addresses, or > should I remove one or the other? ]
I really don't care if I get duplicates. It'll happen anyway when the git mailing list is cc'd. As for which address I prefer, it really doesn't matter to me which one stays in Cc. I'm slowly trying to move everything over to @cs.
Show 35 quoted lines
> Josef Sipek <jsipek@fsl.cs.sunysb.edu> writes:
>
> > On Sun, Jul 29, 2007 at 12:50:15AM -0700, Eric Lesh wrote:
> > ...
> >> diff --git a/guilt b/guilt
> >> index f67bfb5..774909e 100755
> >> --- a/guilt
> >> +++ b/guilt
> >> @@ -178,7 +178,8 @@ get_series()
> >> # - whitespace only
> >> # - optional whitespace followed by '#' followed by more
> >> # optional whitespace
> >> - grep -ve '^[[:space:]]*\(#.*\)*$' "$series"
> >> + # also remove comments from end of lines
> >> + grep -ve '^[[:space:]]*\(#.*\)*$' < "$series" | sed -e 's/[[:space:]]*#.*$//'
> >
> > I'd be tempted to replace the whole thing with one sed script...something
> > like (not tested):
> >
> > "
> > /^[[:space:]]*#/ ! {
> > s/[[:space:]]*#.*$//
> >
> > p
> > }
> > "
> >
>
> sed -e "/^[[:space:]]*\(#.*\)*$/d
> /^[[:space:]]*\(#.*\)*$/!{
> s/[[:space:]]*#.*$//
> }
> " $series
>
> is the best I can do.I think the script I wrote is a bit cleaner as it more easily translates to:
if (!ignore_line) {
strip comment
print
}to make it work, you'd need to run sed with -n to not implicitly print the line.
Jeff.
-- I'm somewhere between geek and normal. - Linus Torvalds