-
Notifications
You must be signed in to change notification settings - Fork 717
/
exec-check.sh
executable file
·43 lines (36 loc) · 1013 Bytes
/
exec-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Find executable files that should not be executable.
set -e
# Files with these extensions may be executable.
allowed_extensions=(
py
sh
)
# Arguments for `find`.
args=(
# Do not look in these directories.
-name .git -prune -o
-name vendor -prune -o
-name scratch -prune -o
# Filter to executable files.
-type f
-executable
# Filter to files with extensions.
-name '*.*'
)
# Filter out files with allowed extensions.
for ext in "${allowed_extensions[@]}"; do
args+=(-not -name "*.${ext}")
done
# Find the names of bad files.
bad_files=$(find . "${args[@]}" -print)
# Fail if any exist.
if [ -n "$bad_files" ]; then
echo -n "##vso[task.logissue type=error]"
echo "The following files should not have their executable bit set:" >&2
echo "$bad_files" >&2
exit 1
fi