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

Prevent error messages while detecting OS #40

Merged
merged 2 commits into from
Oct 23, 2020
Merged

Prevent error messages while detecting OS #40

merged 2 commits into from
Oct 23, 2020

Conversation

Shadow53
Copy link
Contributor

Using tide on openSUSE Tumbleweed causes the following to be printed out when opening a new shell:

cat: /etc/lsb-release: No such file or directory
math: Expected at least 1 args, got 0

This pull request fixes this by short-circuiting _tide_detect_os_linux_cases and returning 1 if the given file does not exist.

Description

At the top of _tide_detect_os_linux_cases, a check was added to test if the given path is a file and, if not, return 1.

Note: I considered using test -e to allow for symbolic links, but decided against it because it also returns true for
directories, which would be invalid. AFAIK, /etc/os-release and /etc/lsb-release are not symlinks on any distros, if they exist, so using -f should be fine? test -L could also be used, but I don't think it checks if the target of the link is a file, and implementing a thorough check using readlink is only something the occurred to me while writing this pull request and seems unnecessary for the files being checked.

How Has This Been Tested

I tested the logic manually in the shell just to be sure, but it's a simple enough line of code that I think it can be verified as correct by looking at it.

  • I have tested using Linux.
  • I have tested using MacOS.

Checklist

I do not think there are any tests for this, since it occurs during installation. If I am wrong, I can go back and modify tests. Similarly, I do not think there is any documentation related to this.

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@IlanCosman
Copy link
Owner

Just made some small stylistic changes. Thanks for the PR @Shadow53 😄

@IlanCosman IlanCosman merged commit f6cf277 into IlanCosman:main Oct 23, 2020
@IlanCosman IlanCosman mentioned this pull request Oct 23, 2020
4 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants