How to check if a program is run in Bash on Ubuntu on Windows and not just plain Ubuntu?

后端 未结 10 600
时光说笑
时光说笑 2020-12-05 02:07

Pretty straightforward, the usual places to figure out the OS you\'re on seem to be identical to plain Ubuntu on Ubuntu for Windows. For example uname -a is ide

10条回答
  •  情深已故
    2020-12-05 02:57

    I just came up with this for my .bashrc for adding some WSL items to $PATH.

    Works in 1703. Not sure if earlier versions.

    if [[ $(uname -r) =~ Microsoft$ ]]; then
        foo
    fi
    

提交回复
热议问题