从 git bash 获取 windows 版本

Get windows version from git bash

我试图在 git-bash shell 脚本中确定 windows10 安装的类型(家庭版与专业版):

if [[ ! $(wmic os get caption) = *"Home"* ]];then
    echo "Not using windows home"
fi

然而,一位法国用户刚刚报告了一个错误,其中 windows 版本以当地语言返回,在本例中为 "Microsoft Windows 10 Famille"。除了将 "Home" 翻译成每种语言之外,有没有更好的方法来确定脚本在面对多种语言时是 运行 在家庭还是在专业?

好吧,我找到的一个解决方案是寻找 windows 专业版而不是 windows 家庭版中存在的 bitlocker 作为功能。

if [[ ! -f /c/Windows/System32/BitLockerWizard.exe ]];then 
    echo "On windows home"
fi