Skip to content

Commit fdb3168

Browse files
authored
Merge pull request #5108 from wanzzhehe/master
Fix adding duplicate paths to PATH during installation
2 parents 95f8740 + b3f9bd3 commit fdb3168

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

scripts/get.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ fi
237237
#
238238
install_profile() {
239239
export XMAKE_ROOTDIR="$prefix/bin"
240-
export PATH="$XMAKE_ROOTDIR:$PATH"
240+
[[ "$PATH" =~ (^|:)"$XMAKE_ROOTDIR"(:|$) ]] || export PATH="$XMAKE_ROOTDIR:$PATH"
241241
xmake --version
242242
xmake update --integrate
243243
}

xmake/actions/update/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function _initialize_shell()
318318
local profile_fish = "$XMAKE_PROGRAM_DIR/scripts/profile-unix.fish"
319319
local bridge_command = format([[export XMAKE_ROOTDIR="%s"
320320
export XMAKE_PROGRAM_DIR="%s"
321-
export PATH="$XMAKE_ROOTDIR:$PATH"
321+
# export PATH="$XMAKE_ROOTDIR:$PATH"
322322
test $FISH_VERSION && test -f "%s" && source "%s" && exit 0
323323
test -f "%s" && source "%s"
324324
]], path.directory(os.programfile()), os.programdir(), profile_fish, profile_fish, profile, profile)

xmake/scripts/profile-unix.fish

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
# @homepage profile-unix.fish
1919
#
2020

21+
# register PATH
22+
string match --regex --quiet "(^|:)$XMAKE_ROOTDIR(:|\$)" "$PATH" || \
23+
export PATH="$XMAKE_ROOTDIR:$PATH"
24+
2125
# register environments
2226
export XMAKE_SHELL=fish
2327

xmake/scripts/profile-unix.sh

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# @homepage profile-unix.sh
1919
#
2020

21+
# register PATH
22+
[[ "$PATH" =~ (^|:)"$XMAKE_ROOTDIR"(:|$) ]] || export PATH="$XMAKE_ROOTDIR:$PATH"
23+
2124
# register completions
2225
if [[ -n "$ZSH_VERSION" ]]; then
2326
export XMAKE_SHELL=zsh

0 commit comments

Comments
 (0)