summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-05-16 19:54:31 +0800
committerGitHub <[email protected]>2024-05-16 19:54:31 +0800
commitfdb3168de1e3e29aa23b88a692ad8c3d7e9f1b83 (patch)
treed7325722719f57dcab069b50d106309f932ec3f5
parent95f874011c27d1145e14b7bb43b0dd578fa6c026 (diff)
parentb3f9bd3dc137f44d84aafc7c28d8495ede9be580 (diff)
Merge pull request #5108 from wanzzhehe/master
Fix adding duplicate paths to PATH during installation
-rwxr-xr-xscripts/get.sh2
-rw-r--r--xmake/actions/update/main.lua2
-rw-r--r--xmake/scripts/profile-unix.fish4
-rw-r--r--xmake/scripts/profile-unix.sh3
4 files changed, 9 insertions, 2 deletions
diff --git a/scripts/get.sh b/scripts/get.sh
index 7cfe5223d..4b9c80156 100755
--- a/scripts/get.sh
+++ b/scripts/get.sh
@@ -237,7 +237,7 @@ fi
#
install_profile() {
export XMAKE_ROOTDIR="$prefix/bin"
- export PATH="$XMAKE_ROOTDIR:$PATH"
+ [[ "$PATH" =~ (^|:)"$XMAKE_ROOTDIR"(:|$) ]] || export PATH="$XMAKE_ROOTDIR:$PATH"
xmake --version
xmake update --integrate
}
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua
index 43ef974a5..f97df2291 100644
--- a/xmake/actions/update/main.lua
+++ b/xmake/actions/update/main.lua
@@ -318,7 +318,7 @@ function _initialize_shell()
local profile_fish = "$XMAKE_PROGRAM_DIR/scripts/profile-unix.fish"
local bridge_command = format([[export XMAKE_ROOTDIR="%s"
export XMAKE_PROGRAM_DIR="%s"
-export PATH="$XMAKE_ROOTDIR:$PATH"
+# export PATH="$XMAKE_ROOTDIR:$PATH"
test $FISH_VERSION && test -f "%s" && source "%s" && exit 0
test -f "%s" && source "%s"
]], path.directory(os.programfile()), os.programdir(), profile_fish, profile_fish, profile, profile)
diff --git a/xmake/scripts/profile-unix.fish b/xmake/scripts/profile-unix.fish
index ea0f243de..e89b1f5cc 100644
--- a/xmake/scripts/profile-unix.fish
+++ b/xmake/scripts/profile-unix.fish
@@ -18,6 +18,10 @@
# @homepage profile-unix.fish
#
+# register PATH
+string match --regex --quiet "(^|:)$XMAKE_ROOTDIR(:|\$)" "$PATH" || \
+ export PATH="$XMAKE_ROOTDIR:$PATH"
+
# register environments
export XMAKE_SHELL=fish
diff --git a/xmake/scripts/profile-unix.sh b/xmake/scripts/profile-unix.sh
index 1695b2331..1f5b69d0c 100644
--- a/xmake/scripts/profile-unix.sh
+++ b/xmake/scripts/profile-unix.sh
@@ -18,6 +18,9 @@
# @homepage profile-unix.sh
#
+# register PATH
+[[ "$PATH" =~ (^|:)"$XMAKE_ROOTDIR"(:|$) ]] || export PATH="$XMAKE_ROOTDIR:$PATH"
+
# register completions
if [[ -n "$ZSH_VERSION" ]]; then
export XMAKE_SHELL=zsh