asdf
asdf copied to clipboard
Bash Strict Mode: Part 1 of 3
Summary
Instead of implementing Bash strict mode in one pull request (as I tried to do with #520 and failed) I am going to do it in three parts:
- Don't allow unset variables (this PR)
- Exit on non-zero exit codes (including in pipes)
- Set a stricter IFS
This PR addresses part of #160
looking over this now :)
@jthegedus build is failing right now. I created this PR on my OSX machine but it looks like things aren't working on Ubuntu. I'm going pull these changes down on my Ubuntu machine and resume working through the remaining issues. I probably won't get to this until late next week though.
No problem. This is a good start to enabling strict mode. I like this process has revealed bugs, proves the effort is valid :smile:
Hey mate, can this be re-based? If I recall it was pretty close to done.
Yes, this is next on my agenda. I will rebase and try to fix the failing tests on Ubuntu tomorrow.
I just rebased this PR onto latest master. I'm hoping to finish this PR update and get it merged soon.
Tag me when you wish to have a review.
I am not sure if we can automate some of these fixes with Shellcheck/Shfmt, but perhaps these proposed changes can be enforced (and potentially auto-fixed) by expanding scripts/stylecheck.py
?
@Stratus3D should we close this?
We can definitely add some stuff to checkstyle.py
to prepare things for set -u
, and I feel reluctant to say this to a 3-year old PR adding this stuff, but in my opinion, errunset
is more trouble than it's worth, especially with ShellCheck.
Unfortunately, I can't think of any way to add the latter two to checkstyle.py
, but maybe there is a way.
@hyperupcall I'm very happy with the level of code quality improvements you have brought to the project over the past year. I don't think this is worth tackling (and assumed Stratus would agree), so thought I would just ask before closing it.
I will just close it though as I think we're all better off spending our time on other issues than this in the short term. We can always dig it back up should we want.
Thanks @jthegedus. I don't have plans to tackle this anymore. I'm focusing my effort on the Rust rewrite.