Remove broken frivolous function from install script #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The "template" installation script contained a
get()
function used to make an HTTP request.The response body is required by the caller, but shell functions do not support returning content as you might do when using a more capable programming language.
As a workaround, the script author set up a system where the caller passed an arbitrary variable name to the function, which the function then assigns with the response body string.
This was done using the
eval
builtin. Theeval
command was quoted in a naive manner, not considering that the body content could contain any arbitrary characters. This made it possible that contents of the response body could be unintentionally executed on the user's machine.In the context of the installation script, this happened under the following conditions:
The most minimal fix would likely have been to change the
eval
command so that the variable containing the response body text was not expanded in the command:However, this problem has provided clear evidence that best practices are to avoid
eval
altogether unless absolutely necessary. Since it is only called once, the entire function is not necessary (and in fact it is questionable whether there is any real value in the entire GitHub releases fallback system). So I decided the best fix was to do away with the function altogether, replacing its single call with the contents of the former function. This removed unnecessary complexity from the script without any decrease in efficiency or increase in maintenance burden.Originally reported at arduino/arduino-cli#1714