Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e83f2fb

Browse files
authored
Merge pull request #264 from sysprog21/check-shell
Check syntax for changed shell scripts
2 parents 06a3780 + c57f37e commit e83f2fb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎scripts/pre-commit.hook

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,21 @@ for FILE in $C_FILES; do
207207
fi
208208
done
209209

210+
# Check syntax for changed shell scripts
211+
SHELL_FILES=()
212+
for file in "${FILES[@]}"; do
213+
if [[ "$file" =~ ^scripts/common\.sh$ || "$file" =~ ^scripts/.*\.hook$ ]]; then
214+
SHELL_FILES+=("$file")
215+
fi
216+
done
217+
if [ "${#SHELL_FILES[@]}" -gt 0 ]; then
218+
for file in "${SHELL_FILES[@]}"; do
219+
if ! bash -n "$file"; then
220+
throw "Syntax errors detected in $file." >&2
221+
fi
222+
done
223+
fi
224+
210225
# Show insertion and deletion counts.
211226
if [ "${#FILES[@]}" -gt 0 ]; then
212227
echo "Following files were changed:"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /