I want to execute a command in a list of directories : gradle --build-cache. Additionnly the directory need to start with the string 'Project" and not ending with "Test". I succeed doing that with this command:
find . -maxdepth 1 -type d \( ! -name . \) -name "Project*" ! -name "*Test*" -exec sh -c "cd '{}' && pwd && gradle --build-cache" \;
But my problem is that the gradle command can fail. If I launch the command alone it returns 'exit 1' but if one of the directory command failed it do not return the fail and the script continue. At the end, the loop return success exit 0...
How can I stop the loop execution when the gradle command failed and return for the general command an exit 1 ?
Thanks :)
findprocess, right? You wantfindto abort when any of the commands started by-execfails? Or just forfindto return an error in that case?gradle --build-cachereturn failed, I want tje whole command (the find one) returns failed