[TynesideLUG] Using bash with the -e option
Ian Bruntlett
ian.bruntlett at gmail.com
Wed Sep 15 18:02:40 UTC 2021
Hi,
I've been told (on accu-general) that running a bash script which contains
this command:-
set -e
Will, normally be useful because if a command returns a non-zero exit code
it is treated as an error and the script is automatically exited.
That is fine but there is a subset of commands (such as grep) that use exit
code slightly differently. For example, grep:-
Normally the exit status is 0 if a line is selected, 1 if no lines were
selected, and 2 if an error occurred. However, if the -q or --quiet or
--silent is used and a line is selected, the exit status is 0 even if an
error occurred.
HTH,
Ian
--
-- ACCU - Professionalism in programming - http://www.accu.org
-- My writing - https://sites.google.com/site/ianbruntlett/
-- Free Software page -
https://sites.google.com/site/ianbruntlett/home/free-software
More information about the Tyneside
mailing list