1
0
Fork 0
mirror of synced 2024-12-12 18:35:46 -05:00

Improve identification of WSL (#196)

Ignore case when searching for Microsoft inside /proc/version.
This commit is contained in:
Tim Byrne 2020-01-20 07:47:31 -06:00
parent 04b98a96cb
commit 76c82c763e
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12
2 changed files with 12 additions and 1 deletions

View file

@ -6,7 +6,7 @@ import pytest
@pytest.mark.parametrize(
'proc_value, expected_os', [
('missing', 'uname'),
('has Microsoft inside', 'WSL'),
('has MiCrOsOfT inside', 'WSL'), # case insensitive
('another value', 'uname'),
], ids=[
'/proc/version missing',

11
yadm
View file

@ -1524,6 +1524,13 @@ function configure_repo() {
function set_operating_system() {
# setting nocasematch to ignore case
local unset_nocasematch
if ! shopt nocasematch &> /dev/null; then
unset_nocasematch=1
fi
shopt -s nocasematch &> /dev/null
# special detection of WSL (windows subsystem for linux)
local proc_version
proc_version=$(cat "$PROC_VERSION" 2>/dev/null)
@ -1545,6 +1552,10 @@ function set_operating_system() {
;;
esac
if [ "$unset_nocasematch" = "1" ]; then
shopt -u nocasematch &> /dev/null
fi
}
function set_awk() {