Skip to content
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

Fix install script's check for previous installation #316

Merged
merged 2 commits into from
Dec 20, 2021
Merged

Fix install script's check for previous installation #316

merged 2 commits into from
Dec 20, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Dec 20, 2021

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 their PATH 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 either 1 or 127 depending on the user's system. The script previously assumed that the exit status would be 1 when the command was not found in PATH, which resulted in spurious advice under these conditions:

https://github.com/arduino/arduino-lint/runs/4577911186?check_suite_focus=true#step:3:11

An existing arduino-lint was found at . Please prepend "/home/runner/work/arduino-lint/arduino-lint/bin" to your $PATH or remove the existing one.

It seems safest to fix this by inverting the logic so that the advice about an existing installation in PATH is only
printed 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

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 their PATH 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 either 1 or 127 depending on the user's system. The script previously assumed that the
exit status would be 1 when the command was not found in PATH, which resulted in spurious advice under these conditions:

```
An existing arduino-lint was found at . Please prepend "/home/foo/arduino-lint/bin" to your $PATH or remove the existing one.
```

It seems safest to fix this by inverting the logic so that the advice about an existing installation in PATH is only
printed when one was found.
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 their PATH environment variable.

This check is done by checking the exit status of `command -v`. The previous use of `$?` for that check was unnecessary
since the command itself can be checked.

This change is required for compliance with ShellCheck rule SC2181:

https://github.com/koalaman/shellcheck/wiki/SC2181
@per1234 per1234 added topic: infrastructure Related to project infrastructure type: imperfection Perceived defect in any part of project labels Dec 20, 2021
@per1234 per1234 self-assigned this Dec 20, 2021
@per1234 per1234 merged commit 21f008c into arduino:main Dec 20, 2021
@per1234 per1234 deleted the fix-install-script branch December 20, 2021 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: infrastructure Related to project infrastructure type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants