Re:With the Rise of DevOps, Perl Shows Its Muscle
by DCoder on Sunday January 08, 2017 @03:29AM
(#13348898)
I use the verbose version for readability:
Some commands need custom error handling, which means turning off -e:
And if you use -e , you will probably need the default value helper to validate input arguments:
[ Parent
| on HN ]
Re:With the Rise of DevOps, Perl Shows Its Muscle
by Ded7xSEoPKYNsDd on Sunday January 08, 2017 @07:20AM
(#13349411)
I feel your first example is better written like this:
if ! ansible-playbook ... ; then
echo -e "\e[1;31m""Error when executing ansible!""\e[0m"
exit 1
fi
But generally when I need to work around errexit, I tend to add something like " || true" or " || xyz_failed=true" to the end of the command line instead of turning it off and on again.