summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 203ee91)
raw | patch | inline | side by side (parent: 203ee91)
author | Junio C Hamano <gitster@pobox.com> | |
Mon, 8 Jun 2009 16:41:49 +0000 (09:41 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 10 Jun 2009 07:02:20 +0000 (00:02 -0700) |
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 <gitster@pobox.com>
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 <gitster@pobox.com>
Makefile | patch | blob | history | |
git-sh-setup.sh | patch | blob | history |
diff --git a/Makefile b/Makefile
index 3890a0e43a973680413b22220bdcf9431b92a0e3..1197b2fd4dcf5eb79f646b7486c45120440670e6 100644 (file)
--- a/Makefile
+++ b/Makefile
-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)
-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 780258135c773180530af4f3ddae95cfe53aec7e..80acb7de729f2f824043b592ce110479d4334a06 100755 (executable)
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
# 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 "$@"