From bc552fd34c8d40b208b33a150a79783644f28b86 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 27 Jan 2021 09:22:53 +0100 Subject: [PATCH] [platform] UNIX launcher: minor optimization GitOrigin-RevId: df3f76222565bbaf1e636f8c1b217f43ae9a9847 --- .../linux/scripts/executable-template.sh | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/platform/build-scripts/resources/linux/scripts/executable-template.sh b/platform/build-scripts/resources/linux/scripts/executable-template.sh index 933517f8dbc7..2daf0f73e212 100755 --- a/platform/build-scripts/resources/linux/scripts/executable-template.sh +++ b/platform/build-scripts/resources/linux/scripts/executable-template.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +# Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. # --------------------------------------------------------------------- # __product_full__ startup script. @@ -56,6 +56,7 @@ IDE_BIN_HOME=$(pwd) IDE_HOME=$("$DIRNAME" "$IDE_BIN_HOME") cd "${OLDPWD}" || exit 2 +CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" PRODUCT_VENDOR="__product_vendor__" PATHS_SELECTOR="__system_selector__" @@ -68,8 +69,8 @@ if [ -n "$__product_uc___JDK" ] && [ -x "$__product_uc___JDK/bin/java" ]; then JDK="$__product_uc___JDK" fi -if [ -z "$JDK" ] && [ -s "${XDG_CONFIG_HOME:-$HOME/.config}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__.jdk" ]; then - USER_JRE=$("$CAT" "${XDG_CONFIG_HOME:-$HOME/.config}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__.jdk") +if [ -z "$JDK" ] && [ -s "${CONFIG_HOME}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__.jdk" ]; then + USER_JRE=$("$CAT" "${CONFIG_HOME}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__.jdk") if [ -x "$USER_JRE/bin/java" ]; then JDK="$USER_JRE" fi @@ -167,23 +168,25 @@ VM_OPTIONS_FILE="" if [ -n "$__product_uc___VM_OPTIONS" ] && [ -r "$__product_uc___VM_OPTIONS" ]; then # explicit VM_OPTIONS_FILE="$__product_uc___VM_OPTIONS" -elif [ -r "$IDE_HOME.vmoptions" ]; then +elif [ -r "${IDE_HOME}.vmoptions" ]; then # Toolbox - VM_OPTIONS_FILE="$IDE_HOME.vmoptions" -elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__$BITS.vmoptions" ]; then + VM_OPTIONS_FILE="${IDE_HOME}.vmoptions" +elif [ -r "${CONFIG_HOME}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__${BITS}.vmoptions" ]; then # user-overridden - VM_OPTIONS_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__$BITS.vmoptions" -elif [ -r "$IDE_BIN_HOME/__vm_options__$BITS.vmoptions" ]; then + VM_OPTIONS_FILE="${CONFIG_HOME}/${PRODUCT_VENDOR}/${PATHS_SELECTOR}/__vm_options__${BITS}.vmoptions" +elif [ -r "${IDE_BIN_HOME}/__vm_options__${BITS}.vmoptions" ]; then # default, standard installation - VM_OPTIONS_FILE="$IDE_BIN_HOME/__vm_options__$BITS.vmoptions" + VM_OPTIONS_FILE="${IDE_BIN_HOME}/__vm_options__${BITS}.vmoptions" else # default, universal package test "$OS_TYPE" = "Darwin" && OS_SPECIFIC="mac" || OS_SPECIFIC="linux" - VM_OPTIONS_FILE="$IDE_BIN_HOME/$OS_SPECIFIC/__vm_options__$BITS.vmoptions" + if [ -r "${IDE_BIN_HOME}/${OS_SPECIFIC}/__vm_options__${BITS}.vmoptions" ]; then + VM_OPTIONS_FILE="${IDE_BIN_HOME}/${OS_SPECIFIC}/__vm_options__${BITS}.vmoptions" + fi fi VM_OPTIONS="" -if [ -r "$VM_OPTIONS_FILE" ]; then +if [ -n "$VM_OPTIONS_FILE" ]; then VM_OPTIONS=$("$CAT" "$VM_OPTIONS_FILE" | "$GREP" -v "^#.*") else message "Cannot find VM options file"