[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: the fine art of error chek'n
From: |
Chris F.A. Johnson |
Subject: |
Re: the fine art of error chek'n |
Date: |
Thu, 7 May 2020 12:02:25 -0400 (EDT) |
User-agent: |
Alpine 2.21 (DEB 202 2017-01-01) |
On Thu, 7 May 2020, address@hidden wrote:
i have written simple programs use'n bash for many years
i most always use something like
false
if (($? != 0)); then echo failed; fi
other than readability what is the difference in the above and
false || echo failed
I would test the command directly:
if ! false ## or whatever you are actually testing
then
echo failed
fi
--
Chris F.A. Johnson <http://cfajohnson.com/>
=========================== Author: ===============================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux shell (2009, Apress)