Chef-client don't exit on command failures in script resource

Hello,
chef-client run is successful even though command fails in below resource. any recommended way to force exit if any of the commands fails in a script resource?

script “testresource” do
interpreter “bash”
user “root”
code <<-EOH
##incorrect command
chonow root:root xyz.txt
ls -l /var/log/messages
EOH
end

What you want is set -x in your bash code. See http://redsymbol.net/articles/unofficial-bash-strict-mode/

“set -x” makes bash scripting verbose. “set -e” makes it error out when any individual command fails. In the code above, several lines of bash script are executing, and the final “ls -l /var/log/messages” is succeeding, which leaves the exit of the bash scripting set to “0”, reporting success. It’s actually worth thinking about what you want to have happen with errors of different parts of a script. In the case above, the word “chown” is misspelled as “chonow”