summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2010-01-16 13:50:22 +0200
committerVille Skyttä <ville.skytta@iki.fi>2010-01-16 13:55:00 +0200
commit45698f2ae8ca9c38748be1893f5f18beb4853962 (patch)
treec3e4561b2cd1fb3c2e55d772f83211a1660bd7ab
parent688f6a0ba66aeb6553c7809eed76116305773f2c (diff)
downloadbash-completion-45698f2ae8ca9c38748be1893f5f18beb4853962.tar.gz
(testsuite) Add simple "lint" script for finding common issues.
Currently flags one potential awk issue in wireless-tools, but that should be a non-issue because wireless-tools is a Linux thing.
-rwxr-xr-xtest/runLint34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/runLint b/test/runLint
new file mode 100755
index 00000000..0f39b56f
--- /dev/null
+++ b/test/runLint
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+gitgrep()
+{
+ local out=$(git grep -I -E -n "$1" | \
+ grep -E '^(bash_completion|contrib/|test/)' | \
+ grep -Fv 'test/runLint')
+ if [ -n "$out" ] ; then
+ printf '***** %s\n' "$2"
+ printf '%s\n\n' "$out"
+ fi
+}
+
+gitgrep "\bawk\b.*-F([[:space:]]|[[:space:]]*[\"'][^\"']{2,})" \
+ 'awk with -F char or -F ERE, use -Fchar instead (Solaris)'
+
+gitgrep '\bsed\b.*\\[?+]' \
+ 'sed with ? or +, use POSIX BRE instead (\{m,n\})'
+
+gitgrep '\bsed\b.*(\(\\?\||\|\\?\))' \
+ "sed with empty alternative in parens, use '\(...\)\{0,1\}' instead"
+
+# TODO: really nonportable? appears to work fine in Linux, FreeBSD, Solaris
+#gitgrep '\bsed\b.*;' \
+# 'sed with ;, use multiple -e options instead (POSIX?) (false positives?)'
+
+gitgrep '\bsed\b.*-[^[:space:]]*[rE]' \
+ 'sed with -r or -E, drop and use POSIX BRE instead'
+
+gitgrep '\b[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)