Skip to content

Commit

Permalink
test/runLint: warn about [ ] instead of [[ ]] use
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 22, 2020
1 parent 6f12de6 commit f6f49db
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/runLint
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/bash -u

gitgrep()
{
local out=$(git grep -I -P -n "$1" | \
grep -E '^(bash_completion|completions/|test/)' | \
grep -Fv 'test/runLint')
local out=$(git grep -I -P -n "$1" |
grep -E '^(bash_completion|completions/|test/)' |
grep -Ev "^test/runLint\>${filter_out:+|$filter_out}")
if [ -n "$out" ]; then
printf '***** %s\n' "$2"
printf '%s\n\n' "$out"
Expand All @@ -15,6 +15,7 @@ unset CDPATH
cd $(dirname "$0")/..

cmdstart='(^|[[:space:]]|\()'
filter_out=

gitgrep $cmdstart"awk\b.*-F([[:space:]]|[[:space:]]*[\"'][^\"']{2,})" \
'awk with -F char or -F ERE, use -Fchar instead (Solaris)'
Expand Down Expand Up @@ -45,3 +46,6 @@ gitgrep '(?<!command)'$cmdstart'(grep|ls|sed)(\s|$)' \
'invoke grep, ls, and sed through "command", e.g. "command grep"'

gitgrep '<<<' 'herestrings use temp files, use some other way'

filter_out='^(test/|bash_completion\.sh)' gitgrep ' \[ ' \
'use [[ ]] instead of [ ]'

0 comments on commit f6f49db

Please sign in to comment.