@@ -6,11 +6,23 @@ COMMIT="@@COMMIT@@"
66APP_NAME=" @@APPNAME@@"
77QUALITY=" @@QUALITY@@"
88NAME=" @@NAME@@"
9-
9+ VSCODE_PATH=" $( dirname " $( dirname " $( realpath " $0 " ) " ) " ) "
10+ ELECTRON=" $VSCODE_PATH /$NAME .exe"
1011if grep -qi Microsoft /proc/version; then
1112 # in a wsl shell
12- WIN_CODE_CMD=$( wslpath -w " $( dirname " $( realpath " $0 " ) " ) /$APP_NAME .cmd" )
13- if ! [ -z " $WIN_CODE_CMD " ]; then
13+ fallback () {
14+ # If running under older WSL, don't pass cli.js to Electron as
15+ # environment vars cannot be transferred from WSL to Windows
16+ # See: https://github.com/Microsoft/BashOnWindows/issues/1363
17+ # https://github.com/Microsoft/BashOnWindows/issues/1494
18+ " $ELECTRON " " $@ "
19+ exit $?
20+ }
21+ WSL_BUILD=$( uname -r | sed -E ' s/^.+-([0-9]+)-Microsoft/\1/' )
22+ # wslpath is not available prior to WSL build 17046
23+ # See: https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-17046
24+ if [ -x /bin/wslpath ]; then
25+ WIN_CODE_CMD=$( wslpath -w " $( dirname " $( realpath " $0 " ) " ) /$APP_NAME .cmd" )
1426 # make sure the cwd is in the windows fs, otherwise there will be a warning from cmd
1527 pushd " $( dirname " $0 " ) " > /dev/null
1628 WSL_EXT_ID=" ms-vscode.remote-wsl"
@@ -21,17 +33,22 @@ if grep -qi Microsoft /proc/version; then
2133 WSL_CODE=$( wslpath -u " ${WSL_EXT_WLOC%% [[:cntrl:]]} " ) /scripts/wslCode.sh
2234 " $WSL_CODE " $COMMIT $QUALITY " $WIN_CODE_CMD " " $APP_NAME " " $@ "
2335 exit $?
36+ elif [ $WSL_BUILD -ge 17063 ] 2> /dev/null; then
37+ # Since WSL build 17063, we just need to set WSLENV so that
38+ # ELECTRON_RUN_AS_NODE is visible to the win32 process
39+ # See: https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-17063
40+ export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV
41+ CLI=$( wslpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
42+ else # $WSL_BUILD ∈ [17046, 17063) OR $WSL_BUILD is indeterminate
43+ fallback " $@ "
2444 fi
45+ else
46+ fallback " $@ "
2547 fi
26- fi
27-
28- VSCODE_PATH=" $( dirname " $( dirname " $( realpath " $0 " ) " ) " ) "
29-
30- if [ -x " $( command -v cygpath) " ]; then
48+ elif [ -x " $( command -v cygpath) " ]; then
3149 CLI=$( cygpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
3250else
3351 CLI=" $VSCODE_PATH /resources/app/out/cli.js"
3452fi
35- ELECTRON=" $VSCODE_PATH /$NAME .exe"
3653ELECTRON_RUN_AS_NODE=1 " $ELECTRON " " $CLI " " $@ "
3754exit $?
0 commit comments