aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/lint.sh
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-06-06 12:31:37 -0700
committerGravatar GitHub <noreply@github.com>2018-06-06 12:31:37 -0700
commit7dbf5caa5f25551658aee614247aed10012166e2 (patch)
tree6696ec6fcd43ab55e0dd8fc927a48ecae7161d0e /scripts/lint.sh
parent2b0f4627383574b09414117985b4d204312b9cc0 (diff)
Fix support scripts on Linux (#1385)
* Make it possible to run style.sh on Linux Needs clang-format in a nonstandard location, but can be made to work. * Fix lint.sh on Linux * Fix multiline comment error
Diffstat (limited to 'scripts/lint.sh')
-rwxr-xr-xscripts/lint.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/scripts/lint.sh b/scripts/lint.sh
index d474129..3d4f453 100755
--- a/scripts/lint.sh
+++ b/scripts/lint.sh
@@ -68,10 +68,21 @@ else
command=(git ls-files)
fi
+# POSIX xargs is required to run commands at least once, but cpplint.py fails
+# (with huge help text) if no files are supplied. Apple xargs avoids invocation
+# if there are no arguments. Use a temporary file to avoid depending on/testing
+# for this feature.
+TEMP=$(mktemp -t lint-files-$$.XXXXXXXXXX)
+trap "rm '$TEMP'" EXIT
+
# Straight C++ files get regular cpplint
"${command[@]}" "${git_options[@]}" \
-- 'Firestore/core/**/*.'{h,cc} \
- | xargs -0 python scripts/cpplint.py --quiet 2>&1
+ > "$TEMP"
+
+if [[ -s "$TEMP" ]]; then
+ xargs -0 python scripts/cpplint.py --quiet 2>&1 < "$TEMP"
+fi
CPP_STATUS=$?
# Objective-C++ files get a looser cpplint
@@ -79,7 +90,10 @@ CPP_STATUS=$?
-- 'Firestore/Source/**/*.'{h,m,mm} \
'Firestore/Example/Tests/**/*.'{h,m,mm} \
'Firestore/core/**/*.mm' \
- | xargs -0 python scripts/cpplint.py "${objc_lint_options[@]}" --quiet 2>&1
+ > "$TEMP"
+if [[ -s "$TEMP" ]]; then
+ xargs -0 python scripts/cpplint.py "${objc_lint_options[@]}" --quiet 2>&1 < "$TEMP"
+fi
OBJC_STATUS=$?
if [[ $CPP_STATUS != 0 || $OBJC_STATUS != 0 ]]; then