Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/resources/linux/bin/code.sh
3520 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
6
# when run in remote terminal, use the remote cli
7
if [ -n "$VSCODE_IPC_HOOK_CLI" ]; then
8
REMOTE_CLI="$(which -a '@@APPNAME@@' | grep /remote-cli/)"
9
if [ -n "$REMOTE_CLI" ]; then
10
"$REMOTE_CLI" "$@"
11
exit $?
12
fi
13
fi
14
15
# test that VSCode wasn't installed inside WSL
16
if grep -qi Microsoft /proc/version && [ -z "$DONT_PROMPT_WSL_INSTALL" ]; then
17
echo "To use @@PRODNAME@@ with the Windows Subsystem for Linux, please install @@PRODNAME@@ in Windows and uninstall the Linux version in WSL. You can then use the \`@@APPNAME@@\` command in a WSL terminal just as you would in a normal command prompt." 1>&2
18
printf "Do you want to continue anyway? [y/N] " 1>&2
19
read -r YN
20
YN=$(printf '%s' "$YN" | tr '[:upper:]' '[:lower:]')
21
case "$YN" in
22
y | yes )
23
;;
24
* )
25
exit 1
26
;;
27
esac
28
echo "To no longer see this prompt, start @@PRODNAME@@ with the environment variable DONT_PROMPT_WSL_INSTALL defined." 1>&2
29
fi
30
31
# If root, ensure that --user-data-dir or --file-write is specified
32
if [ "$(id -u)" = "0" ]; then
33
for i in "$@"
34
do
35
case "$i" in
36
--user-data-dir | --user-data-dir=* | --file-write | tunnel | serve-web )
37
CAN_LAUNCH_AS_ROOT=1
38
;;
39
esac
40
done
41
if [ -z $CAN_LAUNCH_AS_ROOT ]; then
42
echo "You are trying to start @@PRODNAME@@ as a super user which isn't recommended. If this was intended, please add the argument \`--no-sandbox\` and specify an alternate user data directory using the \`--user-data-dir\` argument." 1>&2
43
exit 1
44
fi
45
fi
46
47
if [ ! -L "$0" ]; then
48
# if path is not a symlink, find relatively
49
VSCODE_PATH="$(dirname "$0")/.."
50
else
51
if command -v readlink >/dev/null; then
52
# if readlink exists, follow the symlink and find relatively
53
VSCODE_PATH="$(dirname "$(readlink -f "$0")")/.."
54
else
55
# else use the standard install location
56
VSCODE_PATH="/usr/share/@@APPNAME@@"
57
fi
58
fi
59
60
ELECTRON="$VSCODE_PATH/@@APPNAME@@"
61
CLI="$VSCODE_PATH/resources/app/out/cli.js"
62
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
63
exit $?
64
65