I want to lint all the files in the current (recursive) directory while printing out only files that have an error, and assign a variable to 1 to be used after the linting is finished.
#!/bin/bash
lint_failed=0
find . -path ./vendor -prune -o -name '*.php' | parallel -j 4 sh -c 'php -l {} || echo -e "[FAIL] {}" && lint_failed=1';
if [ "$lint_failed" -eq "1" ]; then
exit 1
fi
Example:
[FAIL] ./app/Model/Example.php
The above code doesn't find any errors, but if I run php -l ./app/Model/Example.php
an error is returned.
jq
– Pneumatophp -l
on that specific file yields an error, I would assume the rest of your code is working fine? Also, where in the given code are you callingphplint
? – Holst