Skip to content

Commit

Permalink
Check grep version
Browse files Browse the repository at this point in the history
  • Loading branch information
vlajos committed Mar 24, 2018
1 parent 4f8f23f commit ceb4976
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions misspell_fixer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ function process_parameter_rules {
return 0
}

function check_grep_version {
local current_version=$(grep --version|head -1|sed -e 's/.* //g')
local required_version="2.28"
if printf '%s\n%s\n' "$required_version" "$current_version" | sort -VC
then
verbose "Your grep version is $current_version which is at least the optimal: $required_version."
else
warning "!! Your grep version is $current_version which is less than the optimal: $required_version. This may degrade misspell fixer's performance significantly! (100x) !!"
fi
}

function preprocess_rules {
grep -vh 'bin/sed' $enabled_rules > $tmpfile.prep.allsedrules
grep '\\b' $tmpfile.prep.allsedrules|sed -e 's/^s\///g' -e 's/\/.*g//g' -e 's/\\b//g' >$tmpfile.prep.grep.rules.w
Expand Down Expand Up @@ -342,6 +353,7 @@ then
then
set -x
fi
check_grep_version
preprocess_rules
main_work prepare_prefilter_input_from_find 0 '' /dev/null
retval=$?
Expand Down
4 changes: 2 additions & 2 deletions test/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ testIgnoreBinary(){
}

testVerbose(){
$RUN -v $TEMP/work 2>&1|sed 's/[0-9]\+/X/g'|grep -v kcov |sort -f >/tmp/verboseoutput
$RUN -v $TEMP/work 2>&1|sed 's/[0-9]\+/X/g'|grep -v -e kcov -e "Your grep version is"|sort -f >/tmp/verboseoutput
diff -ruwb test/stubs/ $TEMP/work/
assertTrue 'Expected output differs.' $?
diff -ruwb /tmp/verboseoutput test/expected.verbose.output
assertTrue 'Expected output differs.' $?
}

testDots(){
$RUN -o $TEMP/work 2>&1|sed 's/[0-9]\+/X/g'|grep -v kcov |sort -f >/tmp/dotsoutput
$RUN -o $TEMP/work 2>&1|sed 's/[0-9]\+/X/g'|grep -v -e kcov -e "Your grep version is"|sort -f >/tmp/dotsoutput
diff -ruwb test/stubs/ $TEMP/work/
assertTrue 'Expected output differs.' $?
diff -ruwb /tmp/dotsoutput test/expected.dots.output
Expand Down

0 comments on commit ceb4976

Please sign in to comment.