On Fri, Dec 11, 2020 at 1:20 PM Rainer Jung <rainer.j...@kippdata.de> wrote:

> Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
> > On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mgrigo...@apache.org>
> > wrote:
> >
> >> Hi Rainer,
> >>
> >> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <rainer.j...@kippdata.de>
> >> wrote:
> >>
> >>> Am 11.12.2020 um 08:25 schrieb mgrigo...@apache.org:
> >>>> This is an automated email from the ASF dual-hosted git repository.
> >>>>
> >>>> mgrigorov pushed a commit to branch master
> >>>> in repository
> >>> https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
> >>>>
> >>>>
> >>>> The following commit(s) were added to refs/heads/master by this push:
> >>>>        new 000c876  Make migrate.sh usable from any directory
> >>>> 000c876 is described below
> >>>>
> >>>> commit 000c876ea3a1e700df2fffef70b29d9c3a9dfef2
> >>>> Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
> >>>> AuthorDate: Fri Dec 11 09:22:22 2020 +0200
> >>>>
> >>>>       Make migrate.sh usable from any directory
> >>>>
> >>>>       Until now one has to `cd` to the bin/ folder to be able to
> execute
> >>> migrate.sh, otherwise lib/ folder won't be found
> >>>> ---
> >>>>    src/main/scripts/migrate.sh | 4 +++-
> >>>>    1 file changed, 3 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/src/main/scripts/migrate.sh b/src/main/scripts/migrate.sh
> >>>> index c2b941c..3d3f34c 100755
> >>>> --- a/src/main/scripts/migrate.sh
> >>>> +++ b/src/main/scripts/migrate.sh
> >>>> @@ -1,4 +1,6 @@
> >>>>    #!/bin/sh
> >>>>
> >>>> +BIN_FOLDER=`dirname $PWD/$0`
> >>>
> >>> Does that work if $0 is an absolute path?
> >>>
> >>
> >> Yes, it does. I have tested it!
> >> BIN_FOLDER looks a bit strange: ///some/absolute/path/bin but it works
> >> just fine on my Ubuntu.
> >> Does it work on Solaris ? :-)
> >>
> >>
> >>>
> >>> Maybe one could
> >>>
> >>>     cd `dirname $0`
> >>>
> >>
> > Two issues with this:
> >
> > 1) the script usage is: ./bin/migrate.sh input.war output.war
> > if we "cd" into bin/ then input.war is not there anymore. Its path should
> > be fixed to ../input.war somehow
> >
> > 2) it would be good to leave the user back to the original directory
> after
> > executing the script but pushd/popd are not available for 'sh'. We will
> > need to use Bash or another
>
> Solaris check:
>
> apache% cat test.sh
> #!/bin/sh
>
> echo `dirname $PWD/$0`
>
> apache% /home/jung/test.sh
> /home/jung//home/jung
>
> apache% ./test.sh
> /home/jung/.
>
> So the full path case does not work there. Switching to /bin/bash or
> /bin/ksh does not help.
>
> I agree with Mark concerning the TC scripts.
>
> Concerning your 2) above: a "cd" in the script does not change the
> working diretory of the calling shell. After the end of the script, the
> user is still in the same directory where he was before starting it.
>
> 1) is a bit more tricky, because again one would have to handle the
> absolute and the relative case.
>
> What might help and should be compatible would be something like
>
> mydir="$PWD"
> cd `dirname "$0"`
> BIN_FOLDER="$PWD"
> cd "$mydir"
>

This works perfect!
Thank you, Rainer!


>
> Regards,
>
> Rainer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

Reply via email to