Ove,
I have in fact determined why I did not use which: On Suse (and Caldera, I believe), which /usr/bin/wine returns an error string, making the whole script go straight down the drain.
What was wrong with the previous implemenation? Are you getting a $0 value that doesn't include the path? In all of the test cases I have, invoking wine seems to bring in a $0 that includes enough of the path for the find logic to work.
Jer
Hunk 2: real_name=`find $0` don't find anything if the user typed "wine" or something, wine is in /usr/bin, which is in PATH, but the cwd is ~... rather run it through `which $0` first. Also, the symlink it's reading don't have to be absolute (my symlinks are relative), deal with that.
-real_name=`find $0 -type l -printf "%l\n"` +argv0_path=`which $0` +if [ -z $argv0_path ] ; then
- argv0_path=$0
+fi
+real_name=`find $argv0_path -type l -printf "%l\n"` if [ ! $real_name ]; then
- real_name=$0;
- real_name=$argv0_path
+elif [ ! -x $real_name ]; then
- real_name=`find $argv0_path -printf "%h\n"`/$real_name
fi
argv0_dir=`find $real_name -printf "%h\n"`
if [ -z $argv0_dir ] ; then @@ -130,7 +138,7 @@ WINESERVER=$WINEBIN/server/wineserver fi
On Tue, 6 Mar 2001, Jeremy White wrote:
What was wrong with the previous implemenation? Are you getting a $0 value that doesn't include the path?
For some reason I did at the time I tried, yes. Doesn't seem to happen anymore, but it's probably not portable (i.e. a bashism?) to assume that $0 is path-expanded anyway, is it?
If "which" is a problem when $0 contains a path, just change it to something like
if [ "$0" = `basename $0` ] then argv0_path=`which "$0"` else argv0_path="$0" fi
or whatever.