Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/resources/win32/versioned/bin/code.sh
5237 views
1
#!/usr/bin/env sh
2
#
3
# Copyright (c) Microsoft Corporation. All rights reserved.
4
# Licensed under the MIT License. See License.txt in the project root for license information.
5
if [ "$VSCODE_WSL_DEBUG_INFO" = true ]; then
6
set -x
7
fi
8
9
COMMIT="@@COMMIT@@"
10
APP_NAME="@@APPNAME@@"
11
QUALITY="@@QUALITY@@"
12
NAME="@@NAME@@"
13
SERVERDATAFOLDER="@@SERVERDATAFOLDER@@"
14
VERSIONFOLDER="@@VERSIONFOLDER@@"
15
VSCODE_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
16
ELECTRON="$VSCODE_PATH/$NAME.exe"
17
18
IN_WSL=false
19
if [ -n "$WSL_DISTRO_NAME" ]; then
20
# $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2
21
IN_WSL=true
22
else
23
WSL_BUILD=$(uname -r | sed -E 's/^[0-9.]+-([0-9]+)-Microsoft.*|.*/\1/')
24
if [ -n "$WSL_BUILD" ]; then
25
if [ "$WSL_BUILD" -ge 17063 ]; then
26
# WSLPATH is available since WSL build 17046
27
# WSLENV is available since WSL build 17063
28
IN_WSL=true
29
else
30
# If running under older WSL, don't pass cli.js to Electron as
31
# environment vars cannot be transferred from WSL to Windows
32
# See: https://github.com/microsoft/BashOnWindows/issues/1363
33
# https://github.com/microsoft/BashOnWindows/issues/1494
34
"$ELECTRON" "$@"
35
exit $?
36
fi
37
fi
38
fi
39
if [ $IN_WSL = true ]; then
40
41
export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV"
42
CLI=$(wslpath -m "$VSCODE_PATH/$VERSIONFOLDER/resources/app/out/cli.js")
43
44
# use the Remote WSL extension if installed
45
WSL_EXT_ID="ms-vscode-remote.remote-wsl"
46
47
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null </dev/null
48
WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt)
49
50
if [ -n "$WSL_EXT_WLOC" ]; then
51
# replace \r\n with \n in WSL_EXT_WLOC
52
WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode.sh
53
"$WSL_CODE" "$COMMIT" "$QUALITY" "$ELECTRON" "$APP_NAME" "$SERVERDATAFOLDER" "$@"
54
exit $?
55
fi
56
57
elif [ -x "$(command -v cygpath)" ]; then
58
CLI=$(cygpath -m "$VSCODE_PATH/$VERSIONFOLDER/resources/app/out/cli.js")
59
else
60
CLI="$VSCODE_PATH/$VERSIONFOLDER/resources/app/out/cli.js"
61
fi
62
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
63
exit $?
64
65