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

Feature request: check if is wsl, windows, mac or linux, maybe also linux distribution #48

Closed
leobastiani opened this issue Jun 30, 2023 · 4 comments
Labels
question Further information is requested

Comments

@leobastiani
Copy link

leobastiani commented Jun 30, 2023

Would you accept PRs?
Could you elaborate anything you would expect to see in a PR?

@Haltarys
Copy link
Contributor

Haltarys commented Jul 3, 2023

Do you want a snippet for each of them ?

@leobastiani
Copy link
Author

it'd be nice I think, I was expecting to find them already and it's something I often search when I'm build scripts to run on a entire team with multiple OSs

@Haltarys
Copy link
Contributor

Haltarys commented Jul 4, 2023

Here are my bash functions to do this:

is_wsl() { [[ -f "/proc/version" ]] && grep -qi WSL "/proc/version"; }
is_ubuntu() { [[ -f "/etc/os-release" ]] && [[ $(awk -F "=" '/^ID=/ {print $2}' "/etc/os-release") = "ubuntu" ]]; }
is_raspbian() { [[ -f "/etc/os-release" ]] && [[ $(awk -F "=" '/^ID=/ {print $2}' "/etc/os-release") = "raspbian" ]]; }
is_macos() { [[ "$(uname -s)" == "Darwin" ]]; }

On Windows, you could use $OSTYPE.

It seems like this repo isn't very actively maintained. I'll try to implement that into my own fork.

@yousefvand yousefvand added the question Further information is requested label Jul 11, 2023
@yousefvand
Copy link
Owner

Would you accept PRs?
Could you elaborate anything you would expect to see in a PR?

Yes PRs are welcome.
Do one change in nsroot each time (add/edit) test it and send it to this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants