diff options
| author | wanzzhehe <[email protected]> | 2024-05-15 15:13:50 +0800 |
|---|---|---|
| committer | wanzzhehe <[email protected]> | 2024-05-15 15:13:50 +0800 |
| commit | c98080e93f0005d3d4f00a22df8633afe2051c85 (patch) | |
| tree | f26233b76d5a9a6e9f43e6a65b19e00ae45bc4a9 | |
| parent | 304943e79b6e2c67d2c010f053d8cd2a42460ddd (diff) | |
Fix repeat add XMAKE_ROOTDIR to PATH in Linux
| -rwxr-xr-x | scripts/get.sh | 2 | ||||
| -rw-r--r-- | xmake/actions/update/main.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/profile-unix.fish | 4 | ||||
| -rw-r--r-- | xmake/scripts/profile-unix.sh | 3 |
4 files changed, 9 insertions, 2 deletions
diff --git a/scripts/get.sh b/scripts/get.sh index 7cfe5223d..f88e9ce7b 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..4811a5f12 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..93dd7157c 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 |
