On Tue, 2007-12-11 at 19:28 -0500, [EMAIL PROTECTED] wrote:
> ...
>
> The goal of my revision to lenya.sh is to make LENYA_HOME independent
> of an environment variable. Before this change, running any of these
> files:
> /lenya-1.2.2/lenya.sh
> /lenya-1.2.5/lenya.sh
> /lenya-1.2.x/lenya.sh
> will start the same instance of Lenya because the environment variable
> overrides the path of the command.
Hmm, should not if you have not set LENYA_HOME in your environment
variables before starting lenya. Otherwise it would not have been
possible to have two different instance on zone running.
> This is not intuitive. When I run
> /lenya-1.2.5/lenya.sh, I expect to launch Lenya 1.2.5, not Lenya
> 1.2.2. More critical, running multiple instances of Lenya is not
> possible when the launch command always reverts to a single instance.
see above.
We had before
if [ "$LENYA_HOME" = "" ] ; then
LENYA_HOME='.'
fi
Meaning when you do not set "$LENYA_HOME" it is the same as you intend
with your commit.
> Editing the lenya.sh of each instance to hardcode the directory
> violates every rule of computing.
Agree, but we have not done that before.
>
> In ash, bash, csh, ksh, and every shell except the original 1977 sh,
> ${0%/*}
> will remove the last slash and anything after the last slash from the command.
>
> echo $0
> returns
> -bash
> because echo is integral to bash so the "command" is bash. Test using
> the following script.
>
> FILE: test.sh
> #!/bin/sh
> echo "PWD= `pwd`"
> LENYA_HOME=${0%/*}
> echo "LH1=$LENYA_HOME"
> cd $LENYA_HOME
> LENYA_HOME=`pwd -P`
> echo "LH2=$LENYA_HOME"
>
> Using people.apache.org:
> /x1$ home/solprovider/test.sh
> PWD= /x1
> LH1=home/solprovider
> LH2=/x1/home/solprovider
>
> In English,
> 1. Get the path used to reach the current executable.
> 2. Change directory using the result of #1. This is relative to the
> current directory. The current directory (PWD) is the directory from
> which the command is called.
> 3. Get the absolute current path. This removes dots and symbolic links.
>
> This code works on every *nix except SunOS. SunOS uses the original
> 1977 shell, which did not have good string manipulation. sh and awk
> were the two required programs for Unix. String manipulation
> required using awk.
Thanks for this detail explanation (the interested reader may refer to
http://issues.apache.org/bugzilla/show_bug.cgi?id=43748 for more
information).
>
> I am ready to rewrite this to use awk to work on SunOS. I am waiting
> for access to zones so I can test the code. I dislike guessing what
> might work and submitting code hoping not to break anything.
>
> Suggestions welcome.
Thanks for tackling this.
However I am not really sure whether this change is needed.
>
> solprovider
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
Thorsten Scherler thorsten.at.apache.org
Open Source Java consulting, training and solutions
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]