Re: [PATCH 1/3] scripts: add spelling_sanitizer.sh script

From: Andy Shevchenko
Date: Fri Jun 11 2021 - 05:43:29 EST


On Fri, Jun 11, 2021 at 12:30 PM Leizhen (ThunderTown)
<thunder.leizhen@xxxxxxxxxx> wrote:
> On 2021/6/11 15:58, Andy Shevchenko wrote:
> > On Fri, Jun 11, 2021 at 10:19 AM Zhen Lei <thunder.leizhen@xxxxxxxxxx> wrote:

...

> >> +# Convert the format of 'codespell' to the current
> >> +sed -r -i 's/ ==> /||/' $src
> >> +
> >> +# Move the spelling "mistake||correction" pairs into file $tmp
> >
> >> +# There are currently 9 lines of comments in $src, so the text starts at line 10
> >> +sed -n '10,$p' $src > $tmp
> >> +sed -i '10,$d' $src
> >
> > This is fragile, use proper comment line detection.
>
> I've thought about that too. But I'm wondering if it needs to be that
> complicated.
>
> Think about it. It's not something for personal temporary use, so it
> should be perfect. I'll change to dynamic computing.

sed has a possibility to choose between two anchors.

Google for `sed -e '/anchor 1/,/anchor 2/'` expressions. So, it will
be less complicated than current code.


--
With Best Regards,
Andy Shevchenko