bashexit-codegnu-findutils

Exit 1 if there any output, otherwise 0


I have the following line on a GitHub Action:

find kubernetes-manifests -regextype egrep -regex '.*ya?ml$' -exec kubeconform "{}" \;

Unfortunately, kubeconform doesn't return 1 or anything else on errors; it is always 0 and some message.

Is it possible to catch the output, check if it is empty, and if it is empty, exit 0; otherwise, echo the output and exit 1?


Solution

  • Switch from \; to + to preserve exit code of kubeconform.