Home > Software design >  Exit 1 if there any output, otherwise 0
Exit 1 if there any output, otherwise 0

Time:01-13

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?

CodePudding user response:

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

  • Related