Skip to content
Permalink
Browse files

[spellcheck] generate sed commands to fix spelling errors

  • Loading branch information
3nids committed Dec 19, 2016
1 parent 2abeea1 commit 6b56e4fbe92f963cc59a507f2f6cead1fc2219e7
Showing with 9 additions and 0 deletions.
  1. +9 −0 scripts/chkspelling_ag.sh
@@ -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

0 comments on commit 6b56e4f

Please sign in to comment.
You can’t perform that action at this time.