Andrew McGlashan via luv-main <[email protected]> writes:

> You can also find extensive discussions in the bug-bash archives on
> why you shouldn't be using set -e, regardless of how many "sources" on
> the web claim that it helps write "robust" or "correct" shell scripts.

If this sort of thing matters to you, it is possibly time for a rewrite
in a "real" programming language, such as Python, Perl, Ruby,
JavaScript, etc.

bash/sh scripts are good for very simple things - e.g. running an
identical sequence of commands exactly the same every time. -e even
works very well in such cases - I prefer using -e when possible - if one
of the commands in the sequence fails, I don't want the sequence to
continue. However, things tend to get very arcade very quickly with
anything slightly more complicated.

As this example clearly shows, with return codes sometimes being used to
return non-error information (e.g. test), and sometimes being used to
convey error/exception information. -e cannot tell the difference.

Or (another common problem I have had) if you want to deal with optional
parameters that might contain spaces. Yes, bash arrays will help, but I
dislike bash arrays.
-- 
Brian May <[email protected]>
https://linuxpenguins.xyz/brian/
_______________________________________________
luv-main mailing list
[email protected]
https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

Reply via email to