Skip to content

Commit 6b56e4f

Browse files
committedDec 19, 2016
[spellcheck] generate sed commands to fix spelling errors
1 parent 2abeea1 commit 6b56e4f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎scripts/chkspelling_ag.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ OUTPUT=$(unbuffer ag --smart-case --all-text --nopager --numbers --word-regexp -
3636

3737
if [[ ! -z $OUTPUT ]]; then
3838
echo "Spelling errors have been found"
39+
echo "****"
40+
# < ---------- get files + error ---------------------------------------------------------------------->
41+
ag --smart-case --only-matching --nogroup --nonumbers --all-text --word-regexp -p $AGIGNORE "$RE" $FILES | \
42+
# <-- generate sed command .... <------------------------------ get correction word -----------------> <------------------------------- match case -------------------------------------------> <-----replace : by / ------> ...finalize sed command>
43+
sed -e 's/\(\S*\):\([[:alnum:]]*\)$/ echo "sed -i s\/"$( echo "\2:$(ag --nonumbers --ignore-case \2 scripts\/spelling.dat | cut -d: -f2)" | sed -r \x27s\/([A-Z]+):(.*)\/\\1:\\U\\2\/; s\/([A-Z][a-z]+):([a-z])\/\\1:\\U\\2\\L\/\x27 | sed -e \x27s\/:\/\\\/\/\x27)"\/ \1" /e' | \
44+
# remove duplicate line
45+
sort -u
46+
echo "****"
47+
echo "Run above commands to fix spelling errors."
3948
exit 1
4049
else
4150
exit 0

0 commit comments

Comments
 (0)
Please sign in to comment.