From 0e0aea5a47b675ab2dca9c77180b8fe9bc6bdeec Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 5 Jun 2009 18:36:15 -0500 Subject: Makefile: introduce SANE_TOOL_PATH for prepending required elements to PATH Some platforms (like SunOS and family) have kept their common binaries at some historical moment in time, and introduced new binaries with modern features in a special location like /usr/xpg4/bin or /usr/ucb. Some of the features provided by these modern binaries are expected and required by git. If the featureful binaries are not in the users path, then git could end up using the less featureful binary and fail. So provide a mechanism to prepend elements to the users PATH at runtime so the modern binaries will be found. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- git-sh-setup.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-sh-setup.sh') diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 838233926f..780258135c 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -11,6 +11,8 @@ # exporting it. unset CDPATH +# @@PATH@@:$PATH + die() { echo >&2 "$@" exit 1 -- cgit v1.3 From 61dbb3c4415169194d9351cc4b68dd88788a93c5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 8 Jun 2009 09:41:49 -0700 Subject: Makefile: insert SANE_TOOL_PATH to PATH before /bin or /usr/bin In an earlier patch, we introduced SANE_TOOL_PATH that is prepended to user's PATH. This had an unintended consequence of overriding user's private binary directory that typically comes earlier in the PATH to holds even saner commands than whatever comes with the system. For example, a user may have ~/bin that is early in the path and contains a shell script "vi" that launches system's /bin/vi with specific options. Prepending SANE_TOOL_PATH to the PATH that happens to have "vi" in it defeats such customization. This fixes the issue by inserting SANE_TOOL_PATH just before /bin or /usr/bin appears on the PATH. Signed-off-by: Junio C Hamano --- Makefile | 7 ++++--- git-sh-setup.sh | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'git-sh-setup.sh') diff --git a/Makefile b/Makefile index 3890a0e43a..1197b2fd4d 100644 --- a/Makefile +++ b/Makefile @@ -881,10 +881,11 @@ endif -include config.mak ifdef SANE_TOOL_PATH -BROKEN_PATH_FIX = s|^. @@PATH@@|PATH=$(SANE_TOOL_PATH)| +SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH)) +BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|' PATH := $(SANE_TOOL_PATH):${PATH} else -BROKEN_PATH_FIX = d +BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d' endif ifeq ($(uname_S),Darwin) @@ -1288,7 +1289,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ - -e '/^# @@PATH@@/$(BROKEN_PATH_FIX)' \ + -e $(BROKEN_PATH_FIX) \ $@.sh >$@+ && \ chmod +x $@+ && \ mv $@+ $@ diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 780258135c..80acb7de72 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -11,7 +11,33 @@ # exporting it. unset CDPATH -# @@PATH@@:$PATH +git_broken_path_fix () { + case ":$PATH:" in + *:$1:*) : ok ;; + *) + PATH=$( + SANE_TOOL_PATH="$1" + IFS=: path= sep= + set x $PATH + shift + for elem + do + case "$SANE_TOOL_PATH:$elem" in + (?*:/bin | ?*:/usr/bin) + path="$path$sep$SANE_TOOL_PATH" + sep=: + SANE_TOOL_PATH= + esac + path="$path$sep$elem" + sep=: + done + echo "$path" + ) + ;; + esac +} + +# @@BROKEN_PATH_FIX@@ die() { echo >&2 "$@" -- cgit v1.3