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

Update os.sh #28

Closed
wants to merge 1 commit into from
Closed

Conversation

chadbrewbaker
Copy link

WSL detection support.

WSL detection support.
@robmorgan
Copy link
Member

@chadbrewbaker looks okay to me. I don't run Windows or WSL but I wanted to check if they publish a /etc/release file?

@@ -36,6 +36,10 @@ function os_is_redhat {
grep -q "Red Hat Enterprise Linux Server release $version" /etc/*release
}

# Returns true (0) if this is a WSL kernel or false (1) otherwise.
function os_is_wsl_kernel {
[[ $(uname -r | tail -c19) == "microsoft-standard" ]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How stable / reliable is looking at column 19? Could that change in a future release?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem brittle... Maybe use grep instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bash supports regex, no need to grep, /etc/os-release would be Ubuntu/Redhat etc, whatever WSL2 container the user has loaded. It's a config string in their build, https://github.com/microsoft/WSL2-Linux-Kernel/blob/master/Microsoft/config-wsl#L22

I used tail instead of head so the version number length is variable.

@ellisonc
Copy link
Contributor

@chadbrewbaker thanks for your contribution. Unfortunately we’ve fallen behind on PRs and are removing old PRs. If this change is still required, we encourage you to re-open.

@ellisonc ellisonc closed this Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants