summaryrefslogtreecommitdiff
path: root/bin/sed
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2006-04-23 15:55:13 +0000
committerAlec Warner <antarus@gentoo.org>2006-04-23 15:55:13 +0000
commit3fc1cef8987a842b62e525f61fb24c0384861cc2 (patch)
tree89f7ecb03308c3f8e13c0bf8a93a9098366226ea /bin/sed
parentset executable bit for sed-wrapper (diff)
downloadportage-multirepo-3fc1cef8987a842b62e525f61fb24c0384861cc2.tar.gz
portage-multirepo-3fc1cef8987a842b62e525f61fb24c0384861cc2.tar.bz2
portage-multirepo-3fc1cef8987a842b62e525f61fb24c0384861cc2.zip
Fix sed breakage for people with weird PATH, fix tabs. Thanks to Flameeyes once again.
svn path=/main/trunk/; revision=3199
Diffstat (limited to 'bin/sed')
-rwxr-xr-xbin/sed28
1 files changed, 15 insertions, 13 deletions
diff --git a/bin/sed b/bin/sed
index c3aff930..6b1a5663 100755
--- a/bin/sed
+++ b/bin/sed
@@ -2,23 +2,25 @@
# Copyright 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+scriptpath=$_
+
if [[ -n ${ESED} ]]; then
-exec ${ESED} "$@"
+ exec ${ESED} "$@"
elif type -p gsed > /dev/null ; then
-exec gsed "$@"
+ exec gsed "$@"
else
-old_IFS="${IFS}"
-IFS=":"
+ old_IFS="${IFS}"
+ IFS=":"
-SEARCH=${PATH#*:}
-for path in $SEARCH; do
-if [[ -x $path/sed ]]; then
-exec $path/sed "$@"
-exit 0
-fi
-done
-
-IFS="${old_IFS}"
+ for path in $PATH; do
+ [[ ${path}/sed == $scriptpath ]] && continue
+ if [[ -x $path/sed ]]; then
+ exec $path/sed "$@"
+ exit 0
+ fi
+ done
+
+ IFS="${old_IFS}"
fi
exit 1