diff options
author | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2017-09-25 23:46:54 -0300 |
---|---|---|
committer | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2017-09-25 23:46:54 -0300 |
commit | 6d88f1055806932d9291f96847d2b691cccda2cd (patch) | |
tree | 0ff79eedaa8a239331256048981deedbd0721965 /test/runLint | |
parent | 059a87a5936cfebfd2d71ab8057002cafb2ea051 (diff) | |
download | bash-completion-6d88f1055806932d9291f96847d2b691cccda2cd.tar.gz |
New upstream version 2.7upstream/2.7
Diffstat (limited to 'test/runLint')
-rwxr-xr-x | test/runLint | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/runLint b/test/runLint new file mode 100755 index 00000000..2db8f358 --- /dev/null +++ b/test/runLint @@ -0,0 +1,45 @@ +#!/bin/bash + +gitgrep() +{ + local out=$(git grep -I -P -n "$1" | \ + grep -E '^(bash_completion|completions/|test/)' | \ + grep -Fv 'test/runLint') + if [ -n "$out" ] ; then + printf '***** %s\n' "$2" + printf '%s\n\n' "$out" + fi +} + +unset CDPATH +cd $(dirname "$0") ; cd .. + +cmdstart='(^|[[:space:]]|\()' + +gitgrep $cmdstart"awk\b.*-F([[:space:]]|[[:space:]]*[\"'][^\"']{2,})" \ + 'awk with -F char or -F ERE, use -Fchar instead (Solaris)' + +gitgrep $cmdstart"awk\b.*\[:[a-z]*:\]" \ + 'awk with POSIX character class not supported in mawk (Debian/Ubuntu)' + +gitgrep $cmdstart'sed\b.*\\[?+]' \ + 'sed with ? or +, use POSIX BRE instead (\{m,n\})' + +gitgrep $cmdstart'sed\b.*\\\|' \ + "sed with \|, use POSIX BRE (possibly multiple sed invocations) or another tool instead" + +# TODO: really nonportable? appears to work fine in Linux, FreeBSD, Solaris +#gitgrep $cmdstart'sed\b.*;' \ +# 'sed with ;, use multiple -e options instead (POSIX?) (false positives?)' + +gitgrep $cmdstart'sed\b.*-[^[:space:]]*[rE]' \ + 'sed with -r or -E, drop and use POSIX BRE instead' + +gitgrep $cmdstart'[ef]grep\b' \ + '[ef]grep, use grep -[EF] instead (historical/deprecated)' + +# TODO: $ in sed subexpression used as an anchor (POSIX BRE optional, not in +# Solaris/FreeBSD) + +gitgrep '(?<!command)'$cmdstart'(grep|ls|sed)(\s|$)' \ + 'invoke grep, ls, and sed through "command", e.g. "command grep"' |