From 76c82c763eb846948c79ec5c2a5d76d413803ad0 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Mon, 20 Jan 2020 07:47:31 -0600 Subject: [PATCH] Improve identification of WSL (#196) Ignore case when searching for Microsoft inside /proc/version. --- test/test_unit_set_os.py | 2 +- yadm | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/test_unit_set_os.py b/test/test_unit_set_os.py index d2f2a2a..e3d93fe 100644 --- a/test/test_unit_set_os.py +++ b/test/test_unit_set_os.py @@ -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', diff --git a/yadm b/yadm index c8e31da..278fcec 100755 --- a/yadm +++ b/yadm @@ -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() {