summaryrefslogtreecommitdiff
path: root/git-sh-setup.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-06-08 09:41:49 -0700
committerJunio C Hamano <gitster@pobox.com>2009-06-10 00:02:20 -0700
commit61dbb3c4415169194d9351cc4b68dd88788a93c5 (patch)
treebad5939021f57fead20db7690b2b4a5bd41b5c76 /git-sh-setup.sh
parent203ee91fd273ae424deeeee5ddcc7947a4c76ccd (diff)
downloadgit-61dbb3c4415169194d9351cc4b68dd88788a93c5.tar.gz
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 <gitster@pobox.com>
Diffstat (limited to 'git-sh-setup.sh')
-rwxr-xr-xgit-sh-setup.sh28
1 files changed, 27 insertions, 1 deletions
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 "$@"