@@ -13,40 +13,46 @@ NAME="@@NAME@@"
1313DATAFOLDER=" @@DATAFOLDER@@"
1414VSCODE_PATH=" $( dirname " $( dirname " $( realpath " $0 " ) " ) " ) "
1515ELECTRON=" $VSCODE_PATH /$NAME .exe"
16- if grep -qi Microsoft /proc/version; then
17- # in a wsl shell
18- WSL_BUILD=$( uname -r | sed -E ' s/^[0-9.]+-([0-9]+)-Microsoft.*|([0-9]+).([0-9]+).([0-9]+)-microsoft.*|.*/\1\2\3\4/' )
19- if [ -z " $WSL_BUILD " ]; then
20- WSL_BUILD=0
16+
17+ IN_WSL=false
18+ if [ -n " $WSL_DISTRO_NAME " ]; then
19+ # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2
20+ IN_WSL=true
21+ else
22+ WSL_BUILD=$( uname -r | sed -E ' s/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/' )
23+ if [ -n " $WSL_BUILD " ]; then
24+ if [ " $WSL_BUILD " -ge 17063 ]; then
25+ # WSLPATH is available since WSL build 17046
26+ # WSLENV is available since WSL build 17063
27+ IN_WSL=true
28+ else
29+ # If running under older WSL, don't pass cli.js to Electron as
30+ # environment vars cannot be transferred from WSL to Windows
31+ # See: https://github.com/Microsoft/BashOnWindows/issues/1363
32+ # https://github.com/Microsoft/BashOnWindows/issues/1494
33+ " $ELECTRON " " $@ "
34+ exit $?
35+ fi
2136 fi
37+ fi
38+ if [ $IN_WSL = true ]; then
2239
23- if [ $WSL_BUILD -ge 17063 ]; then
24- # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2
25- # WSLPATH is available since WSL build 17046
26- # WSLENV is available since WSL build 17063
27- export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV
28- CLI=$( wslpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
40+ export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV
41+ CLI=$( wslpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
2942
30- # use the Remote WSL extension if installed
31- WSL_EXT_ID=" ms-vscode-remote.remote-wsl"
43+ # use the Remote WSL extension if installed
44+ WSL_EXT_ID=" ms-vscode-remote.remote-wsl"
3245
33- ELECTRON_RUN_AS_NODE=1 " $ELECTRON " " $CLI " --locate-extension $WSL_EXT_ID > /tmp/remote-wsl-loc.txt 2> /dev/null
34- WSL_EXT_WLOC=$( cat /tmp/remote-wsl-loc.txt)
46+ ELECTRON_RUN_AS_NODE=1 " $ELECTRON " " $CLI " --locate-extension $WSL_EXT_ID > /tmp/remote-wsl-loc.txt 2> /dev/null
47+ WSL_EXT_WLOC=$( cat /tmp/remote-wsl-loc.txt)
3548
36- if [ -n " $WSL_EXT_WLOC " ]; then
37- # replace \r\n with \n in WSL_EXT_WLOC
38- WSL_CODE=$( wslpath -u " ${WSL_EXT_WLOC%% [[:cntrl:]]} " ) /scripts/wslCode.sh
39- " $WSL_CODE " " $COMMIT " " $QUALITY " " $ELECTRON " " $APP_NAME " " $DATAFOLDER " " $@ "
40- exit $?
41- fi
42- else
43- # If running under older WSL, don't pass cli.js to Electron as
44- # environment vars cannot be transferred from WSL to Windows
45- # See: https://github.com/Microsoft/BashOnWindows/issues/1363
46- # https://github.com/Microsoft/BashOnWindows/issues/1494
47- " $ELECTRON " " $@ "
49+ if [ -n " $WSL_EXT_WLOC " ]; then
50+ # replace \r\n with \n in WSL_EXT_WLOC
51+ WSL_CODE=$( wslpath -u " ${WSL_EXT_WLOC%% [[:cntrl:]]} " ) /scripts/wslCode.sh
52+ " $WSL_CODE " " $COMMIT " " $QUALITY " " $ELECTRON " " $APP_NAME " " $DATAFOLDER " " $@ "
4853 exit $?
4954 fi
55+
5056elif [ -x " $( command -v cygpath) " ]; then
5157 CLI=$( cygpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
5258else
0 commit comments