-
Notifications
You must be signed in to change notification settings - Fork 237
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
Make the install script a little bit safer when being piped #352
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #352 +/- ##
===========================================
- Coverage 28.00% 27.59% -0.41%
===========================================
Files 42 21 -21
Lines 4795 2732 -2063
===========================================
- Hits 1343 754 -589
+ Misses 3267 1892 -1375
+ Partials 185 86 -99 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restating how this works to make sure I'm understanding it right.
With the function wrapping everything, trap
would exit the install
function on an ERR
signal from any command within install
. Without the the install
wrapper, trap
would call error
after a command like curl
raised an ERR
signal, but the next line of code would still execute. Does that match what happened before and after?
This shouldn't make a difference to trap - I did a local test of making a command fail and it printed the error as before. The main difference now is that when you run the script as Wrapping in a function like this ensures that instead of executing half of the commands, we only define half of a function - nothing will be executed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing it out there that you now how nested functions which feels like an anti-pattern. I think should just shuffle this a bit to move error
above install
and also get consistent indentation so it's obvious the rest belongs in the function. And, a pedantic nit, but I prefer such "do all the things" functions to be called main
to really capture intention.
@glenjamin have you had a chance to consider @taxonomic-blackfish 's suggestions? We'd like to pick this pr back up but would also like to make sure the logic is up to date and applicable. |
c0af73d
to
be8c3cc
Compare
be8c3cc
to
15acfb8
Compare
Perhaps this is platform/shell specific, but this seems to introduce a bug because of a name collision with the
|
If the connection cut out midway through, the script would partially execute.
Wrapping in a function ensures that nothing will be executed unless the file is fully downloaded