Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix discovering executable files on macOS #106

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/scandir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ jobs:

- name: Verify check
run: |
expect="testfiles/scandir/run[[:space:]]me.bash"
expect1="testfiles/scandir/run[[:space:]]me.bash"
expect2="testfiles/scandir/exec"
notexpect="testfiles/test.bash"

if [[ ! "${{ steps.one.outputs.files }}" =~ $expect ]];then
echo "::error:: Expected file $expect not found in ${{ steps.one.outputs.files }}"
if [[ ! "${{ steps.one.outputs.files }}" =~ $expect1 ]];then
echo "::error:: Expected file $expect1 not found in ${{ steps.one.outputs.files }}"
exit 1
elif [[ ! "${{ steps.one.outputs.files }}" =~ $expect2 ]];then
echo "::error:: Expected file $expect2 not found in ${{ steps.one.outputs.files }}"
exit 1
elif [[ "${{ steps.one.outputs.files }}" =~ $notexpect ]];then
echo "::error:: Expected file $notexpect found in ${{ steps.one.outputs.files }}"
Expand Down
6 changes: 5 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ runs:
')' \
-print0)

perm_executable="/111"
# BSD find on macOS does not support the slash syntax for permissions.
[ "$(uname -s)" = "Darwin" ] && perm_executable="+111"
mislav marked this conversation as resolved.
Show resolved Hide resolved

while IFS= read -r -d '' file; do
head -n1 "$file" | grep -Eqs "$shebangregex" || continue
filepaths+=("$file")
done < <(find "${INPUT_SCANDIR}" \
${INPUT_EXCLUDE_ARGS} \
-type f ! -name '*.*' -perm /111 \
-type f ! -name '*.*' -perm "$perm_executable" \
-print0)

if [[ -n "${INPUT_CHECK_TOGETHER}" ]]; then
Expand Down
3 changes: 3 additions & 0 deletions testfiles/scandir/exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

echo "I am executable"