Fixed WinNT10 detection

This commit is contained in:
deajan 2016-11-22 18:50:09 +01:00
parent 15630c4b6d
commit b3d17f8fec
1 changed files with 25 additions and 18 deletions

View File

@ -1,6 +1,6 @@
#### MINIMAL-FUNCTION-SET BEGIN #### #### MINIMAL-FUNCTION-SET BEGIN ####
## FUNC_BUILD=2016112203 ## FUNC_BUILD=2016112204
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## To use in a program, define the following variables: ## To use in a program, define the following variables:
@ -960,15 +960,19 @@ function GetLocalOS {
# There's no good way to tell if currently running in BusyBox shell. Using sluggish way. # There's no good way to tell if currently running in BusyBox shell. Using sluggish way.
if ls --help 2>&1 | grep -i "BusyBox" > /dev/null; then if ls --help 2>&1 | grep -i "BusyBox" > /dev/null; then
localOsVar="BusyBox" localOsVar="BusyBox"
# Detecting the special ubuntu userland in Windows 10 bash
elif [ -f /proc/sys/kernel/osrelease ]; then
localOsVar="$(cat /proc/sys/kernel/osrelease)"
else else
localOsVar="$(uname -spio 2>&1)" # Detecting the special ubuntu userland in Windows 10 bash
if [ $? != 0 ]; then if [ -f /proc/sys/kernel/osrelease ]; then
localOsVar="$(uname -v 2>&1)" if grep -i Microsoft /proc/sys/kernel/osrelease > /dev/null; then
if [ $? != 0 ]; then localOsVar="Microsoft"
localOsVar="$(uname)" else
localOsVar="$(uname -spio 2>&1)"
if [ $? != 0 ]; then
localOsVar="$(uname -v 2>&1)"
if [ $? != 0 ]; then
localOsVar="$(uname)"
fi
fi
fi fi
fi fi
fi fi
@ -1027,19 +1031,22 @@ function GetOs {
# There's no good way to tell if currently running in BusyBox shell. Using sluggish way. # There's no good way to tell if currently running in BusyBox shell. Using sluggish way.
if ls --help 2>&1 | grep -i "BusyBox" > /dev/null; then if ls --help 2>&1 | grep -i "BusyBox" > /dev/null; then
localOsVar="BusyBox" localOsVar="BusyBox"
elif [ -f /proc/sys/kernel/osrelease ]; then
localOsVar="$(cat /proc/sys/kernel/osrelease)"
else else
localOsVar="$(uname -spio 2>&1)" # Detecting the special ubuntu userland in Windows 10 bash
if [ $? != 0 ]; then if [ -f /proc/sys/kernel/osrelease ]; then
localOsVar="$(uname -v 2>&1)" if grep -i Microsoft /proc/sys/kernel/osrelease > /dev/null; then
if [ $? != 0 ]; then localOsVar="Microsoft"
localOsVar="$(uname)" else
localOsVar="$(uname -spio 2>&1)"
if [ $? != 0 ]; then
localOsVar="$(uname -v 2>&1)"
if [ $? != 0 ]; then
localOsVar="$(uname)"
fi
fi
fi fi
fi fi
fi fi
echo "$localOsVar" echo "$localOsVar"
} }