Skip to content

Commit

Permalink
[spellcheck] generate sed commands to fix spelling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Dec 19, 2016
1 parent 2abeea1 commit 6b56e4f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/chkspelling_ag.sh
Expand Up @@ -36,6 +36,15 @@ OUTPUT=$(unbuffer ag --smart-case --all-text --nopager --numbers --word-regexp -

if [[ ! -z $OUTPUT ]]; then
echo "Spelling errors have been found"
echo "****"
# < ---------- get files + error ---------------------------------------------------------------------->
ag --smart-case --only-matching --nogroup --nonumbers --all-text --word-regexp -p $AGIGNORE "$RE" $FILES | \
# <-- generate sed command .... <------------------------------ get correction word -----------------> <------------------------------- match case -------------------------------------------> <-----replace : by / ------> ...finalize sed command>
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' | \
# remove duplicate line
sort -u
echo "****"
echo "Run above commands to fix spelling errors."
exit 1
else
exit 0
Expand Down

0 comments on commit 6b56e4f

Please sign in to comment.