-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use 'set -o errexit' to catch script errors #89
Comments
As I noted at LSF 2023, I think this is a good idea. Yesterday, I found time to work on this, and did a trial implementation: a99d840. With this change, I observed many test cases fail or show weird behavior as @hreinecke indicated. It looks like certain amount of work is required to fix them all. I will spend some more time and see how much work will be required. |
Is |
Thanks for the comment. I will user |
I've spent some time on the errexit support. The number of affected test cases are not so small, but it looks possible to modify them to meet the errexit requirements. Around a dozen of patches will be required. WIP code is available at my errexit branch. Through this work, I noticed following points:
In short, this errexit support work needs larger effort than I expected. I will rethink priority of this work. I think nbd/002,003 improvement and clean-up improvement will have higher priority. |
How about using this alternative for ignoring an error status:
|
That will work too, and could be easier to understand for some people :) One drawback is that this needs more types than "|| true". This made me think of creating a new helper function like _ok() or _ignore_status(). With these it will be "|| _ok" or "|| _ignore_status", and these might be a bit easier to understand than "|| true". |
Heya,
bash has the option 'errexit' (invoked via 'set -o errexit'), which will cause the script to abort if a command/line returns 'false'.
This has the nice effect that any errors are catched automatically, and don't have to be checked for.
With that we'll be able to catch silent failures which are currently ignored.
Drawback is that one gets lots of false positive initially, as every command which should be ignored need to be suffixed by ' || true'.
But it's a very good thing for hardening the scripts; I've had quite good experience with that when developing testcases for md_monitor
The text was updated successfully, but these errors were encountered: