code.sh 1.0 KB
Newer Older
D
Daniel Imms 已提交
1
#!/usr/bin/env bash
D
Daniel Imms 已提交
2 3 4
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
D
Daniel Imms 已提交
5

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# If root, ensure that --user-data-dir is specified
if [ "$(id -u)" = "0" ]; then
	while test $# -gt 0
	do
		if [[ $1 == --user-data-dir=* ]]; then
			DATA_DIR_SET=1
		fi
		shift
	done
	if [ -z $DATA_DIR_SET ]; then
		echo "It is recommended to start vscode as a normal user. To run as root, you must specify an alternate user data directory with the --user-data-dir argument." 1>&2
		exit 1
	fi
fi

21 22 23 24 25 26 27 28 29 30 31 32
if [ ! -L $0 ]; then
	# if path is not a symlink, find relatively
	VSCODE_PATH="$(dirname $0)/.."
else
	if which readlink >/dev/null; then
		# if readlink exists, follow the symlink and find relatively
		VSCODE_PATH="$(dirname $(readlink $0))/.."
	else
		# else use the standard install location
		VSCODE_PATH="/usr/share/@@NAME@@"
	fi
fi
33

34
ELECTRON="$VSCODE_PATH/@@NAME@@"
35
CLI="$VSCODE_PATH/resources/app/out/cli.js"
36
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
37
exit $?