I found another way to solve this:
set +e
find "./csharp/Platform.$REPOSITORY_NAME/obj" -type f -iname "*.cs" -delete
find "./csharp/Platform.$REPOSITORY_NAME.Tests/obj" -type f -iname "*.cs" -delete
set -e
You can turn off failing on errors by set +e
this will now ignore all errors after that line. Once you are done, and you want the script to fail again on any error, you can use set -e
.
After applying set +e
the find
does not fail the whole script anymore, when files are not found. At the same time, error messages
from find
are still printed, but the whole script continues to execute. So it is easy to debug if that causes the problem.
This is useful for CI & CD (for example in GitHub Actions).
-e
attribute is set "if the command that fails is part of the command list immediately following awhile
oruntil
keyword, part of the test in anif
statement, part of any command executed in a&&
or||
list except the command following the final&&
or||
, any command in a pipeline but the last, or if the command's return status is being inverted with!
." – Rabato