sourcegraph/dev/check/shfmt.sh
TJ DeVries e2c2857120
lsif typed syntax highlighter v0.1 (#30016)
* (syntax-highlighter): tree-sitter,lsif-typed

* lsif_typed -> lsiftyped

* doc updates

* update docker images to match .tool-versions

* fixup: Remove submodules when running backcompat tests
2022-02-23 11:44:17 -05:00

27 lines
603 B
Bash
Executable File

#!/usr/bin/env bash
echo "--- shfmt (ensure shell-scripts are formatted consistently)"
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"/../..
set +e
# Ignore scripts in submodules
#
# Following command uses `git ls-files` to make sure we have only files that
# are in our repository, and then `shfmt -f .` to find the shell scripts.
#
# `comm` is used to find the common items between the two
OUT=$(comm -12 <(git ls-files | sort) <(shfmt -f . | sort) | shfmt -d)
EXIT_CODE=$?
set -e
echo -e "$OUT"
if [ $EXIT_CODE -ne 0 ]; then
echo -e "$OUT" >./annotations/shfmt
echo "^^^ +++"
fi
exit $EXIT_CODE