Exit 1 if there any output, otherwise 0

129 views Asked by At

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?

1

There are 1 answers

0
Cyrus On BEST ANSWER

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