Skip to content

Commit c77975a

Browse files
committed
pre-commit-hook.sh: Check for prelude.sh call on the 2nd line
1 parent 0c55add commit c77975a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

StaticAnalysis/prelude_rearrange.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
. ../prelude.sh
23
set -euo pipefail
34

45
# Find all .sh files and process each one

pre-commit-hook.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,15 @@ find . -type f -name "*.sh" -print0 \
3333
# I am passing the filename as a parameter to the bash subshell
3434
# find . -type f -name "*.sh" -execdir \
3535
# bash -c 'echo "### Entering directory $(pwd)" && shellcheck "${1}"' bash {} \;
36+
#
37+
38+
find . -type f -name '*.sh' \( \
39+
! -name "prelude.sh" \
40+
\) -print0 \
41+
| while IFS= read -r -d '' f; do
42+
if ! sed -n '2p' "$f" \
43+
| grep -Eq '^\.[[:space:]]+(\.\./)*prelude\.sh$'; then
44+
err "File does not have . prelude.sh on the 2nd line: $f"
45+
exit 2
46+
fi
47+
done

0 commit comments

Comments
 (0)