Fix install script's check for previous installation #316
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 installation script checks for an existing installation in the
PATH
in order to provide appropriate advice to the user about adding the installation to their theirPATH
environment variable.This check is done using
command -v
. It turns out that the exit status is shell dependent in the event the command is not found, so that it might be either1
or127
depending on the user's system. The script previously assumed that the exit status would be1
when the command was not found inPATH
, which resulted in spurious advice under these conditions:https://github.com/arduino/arduino-lint/runs/4577911186?check_suite_focus=true#step:3:11
It seems safest to fix this by inverting the logic so that the advice about an existing installation in
PATH
is onlyprinted when one was found.
Attains sync with upstream "template" script: arduino/tooling-project-assets#189
Checks for proper behavior of this aspect have been added for the parent: https://github.com/arduino/tooling-project-assets/actions/runs/1601562939
Originally reported at https://forum.arduino.cc/t/failing-to-instlal-arduino-cli-on-raspberry/936871