Joseph S. Myers wrote:
> On Tue, 29 May 2012, Jim Meyering wrote:
>
>> Running the following command spots over 1500 typos, and suggests fixes:
>>
>> $ git ls-files|misspellings -f -|grep -v '^ERROR:'|perl -pe \
>> 's/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/sed -i '\''${2}s!$3!$4!'\'' $1/' > k
>
> This command has some bugs in how it produces fixes, fixing them would
> make the output more useful in some cases:
>
>> sed -i '1811s!MISCELANEOUS!Miscellaneous!' gcc/config/mn10300/mn10300.md
>
> Should preserve the case of all-uppercase words.
I suppose that would be useful.
>> sed -i '2102s!hasnt!hasn't!' gcc/config/picochip/picochip.c
>
> Needs to allow for the ' in the replacement string.
I can do that on the command line, but it may not be worth it.
It's getting pretty ugly:
git ls-files|misspellings -f -|grep -v '^ERROR:'|perl -p \
-e '/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/ or next;' \
-e '($file,$N,$L,$R)=($1,$2,$3,$4); $q="'\''"; $R=~s/$q/$q\\$q$q/g;' \
-e 's/.*/sed -i $q${N}s!$L!$R!$q $file/'
I.e., it would print this:
sed -i '2102s!hasnt!hasn'\''t!' gcc/config/picochip/picochip.c