]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Fix some issues that mangled the reexecution path to a script,
authorGary V. Vaughan <gary@gnu.org>
Fri, 8 Oct 2004 15:50:56 +0000 (15:50 +0000)
committerGary V. Vaughan <gary@gnu.org>
Fri, 8 Oct 2004 15:50:56 +0000 (15:50 +0000)
and thus prevented it from finding itself:

* lib/general.m4sh (progname): Don't actually change the name of
the script if it begins with a `-', just prepend `./'.
(progpath): Add a new clause that first searches the execution
PATH, and then finally assumes this script is in the current
working directory if $progname has no directory separators (e.g
when invoked as `$SHELL progname').

ChangeLog
config/general.m4sh

index c53358dd28549c9f7e7f6812b58135d9ec910148..e5ab34e8e8b5667b618e1a6ed784e70466aba29d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-10-08  Gary V. Vaughan  <gary@gnu.org>
+
+       Fix some issues that mangled the reexecution path to a script,
+       and thus prevented it from finding itself:
+
+       * config/general.m4sh (progname): Don't actually change the name
+       of the script if it begins with a `-', just prepend `./'.
+       (progpath): Add a new clause that first searches the execution
+       PATH, and then finally assumes this script is in the current
+       working directory if $progname has no directory separators (e.g
+       when invoked as `$SHELL progname').
+
 2004-10-08  Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
 
        * libltdl/ltdl.c (lt_dlexit, lt_dlpath_insertdir): Fix memleaks,
index d5eab8587edadbae81d0a51bc32193e0e417acf5..6ddc1655e0aaff92ae63078d6599df09f593e73c 100644 (file)
@@ -62,16 +62,28 @@ progpath="$0"
 
 # The name of this program:
 # In the unlikely event $progname began with a '-', it would play havoc with
-# func_echo (imagine progname=-n), so we substitute for _ in that case.
-progname=`$ECHO "X$progpath" | $Xsed -e "$basename" -e 's,^-,_,'`
+# func_echo (imagine progname=-n), so we prepend ./ in that case:
+progname=`$ECHO "X$progpath" | $Xsed -e "$basename" -e 's,^-,./-,'`
 
 # Make sure we have an absolute path for reexecution:
 case $progpath in
   [[\\/]]*|[[A-Za-z]]:\\*) ;;
-  *) progdir=`$ECHO "X$progpath" | $Xsed -e "$dirname"`
+  *[[\\/]]*)
+     progdir=`$ECHO "X$progpath" | $Xsed -e "$dirname"`
      progdir=`cd "$progdir" && pwd`
      progpath="$progdir/$progname"
      ;;
+  *)
+     save_IFS="$IFS"
+     IFS=:
+     for progdir in $PATH; do
+       IFS="$save_IFS"
+       test -x "$progdir/$progname" && break
+     done
+     IFS="$save_IFS"
+     test -n "$progdir" || progdir=`pwd`
+     progpath="$progdir/$progname"
+     ;;
 esac
 
 # Sed substitution that helps us do robust quoting.  It backslashifies