[skip changelog] Improve install script's check for conflicting installation in $PATH #822
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.
Please check if the PR fulfills these requirements
Bug fix
The installation script's check for a conflicting prior installation in
$PATH
was prone to false positives. For example, any of these examples result in a spurious "An existing arduino-cli was found at..." error:$PATH
:When the check for conflicting installation in
$PATH
has a positive, a "Failed to install arduino-cli" error message is displayed, even though the installation was successful.When the check for conflicting installation in
$PATH
has a positive, the script has exit status 1, even though this positive does not really represent an error.The check for conflicting installation in
$PATH
is made more robust by comparing the resolved, absolute paths.When the check for conflicting installation in
$PATH
has a positive, no confusing "Failed to install arduino-cli" error message is displayed.When the check for conflicting installation in
$PATH
has a positive, it prints a helpful warning, but the script's exit status is 0.The script no longer returns exit status 1 when a conflicting installation in
$PATH
is detected. This is a breaking change for anyone relying on the previous behavior. However, I think this is unlikely.If you want to test the modified script using the recommended installation method, the command is:
My initial instinct for improving the comparison was to use the
-ef
file test operator, but that is bash-specific while the install script specifies sh.It didn't end up being relevant to this work, but I'll add the information here for future reference since I had trouble finding it: The original base for the install script is here: https://github.com/Masterminds/glide.sh/blob/master/get, not in the repository mentioned by the comment in the script.