Rodrigo
Rodrigo

Reputation: 431

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?

Upvotes: 0

Views: 149

Answers (1)

Cyrus
Cyrus

Reputation: 88999

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

Upvotes: 1

Related Questions