You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mg...@apache.org on 2020/12/11 07:25:01 UTC

[tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

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 <mg...@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`
+
 # Assumes java is on the path
-java -cp "../lib/*" org.apache.tomcat.jakartaee.MigrationCLI "$@"
+java -cp "$BIN_FOLDER/../lib/*" org.apache.tomcat.jakartaee.MigrationCLI "$@"


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Martin,

On 12/11/20 15:52, Martin Grigorov wrote:
> On Fri, Dec 11, 2020, 21:34 Christopher Schultz <
> chris@christopherschultz.net> wrote:
> 
>> Rainer,
>>
>> On 12/11/20 14:19, Rainer Jung wrote:
>>> Hi Chris,
>>>
>>> Am 11.12.2020 um 19:53 schrieb Christopher Schultz:
>>>> Rainer,
>>>>
>>>> On 12/11/20 06:19, Rainer Jung wrote:
>>>>> Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
>>>>>> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <
>> mgrigorov@apache.org>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Rainer,
>>>>>>>
>>>>>>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <
>> rainer.jung@kippdata.de>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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"
>>>>
>>>> I would avoid using "cd" in a script if at all possible. The migration
>>>> tool should be able to be run from anywhere with command-line
>>>> arguments to anything you need to call (e.g. java -cp).
>>>
>>> What risk do you see in the two "cd" uses? How is the ability to be
>>> called from anywhere reduced by teh above construct? It was actually
>>> introduced to myke it callable from anywhere.
>>
>> The whole script can be:
>>
>> BIN_FOLDER=$( dirname ${0} )
>> java -cp "$BIN_FOLDER/../lib/*" org.apache.tomcat.jakartaee.MigrationCLI
>> "$@"
>>
>> The "cd" is not necessary at all and IMO is just more complicated.
>>
>> Note that the "-cp" won't work because the files must be separated by :
>> on *NIX. Unless I don't know how to build this in Maven (which is weird,
>> I have no mvnw command to run, so I did "mvn verify" which did build a
>> .jar file), there won't be any lib directory to include.
>>
>> Don't we really just want:
>>
>> BIN_FOLDER=$( dirname ${0} )
>> java -jar "$BIN_FOLDER/target/jakartaee-migration-0.1.0.jar" \
>>     org.apache.tomcat.jakartaee.MigrationCLI "$@"
>>
>> ?
>>
>> Maybe I just don't understand what this script is intended to
>> accomplish. A shortcut for "java -jar [migration-tool]" or something else?
>>
>> Every Java-related shell script I ever write looks something like this:
>>
>> #/bin/sh
>> BIN_DIR=$( dirname ${0} )
>>
> 
> dirname just cuts the parent path segment.
> If there is no such then it returns '.'
> Play with it and see.

Yes, then you get BIN_DIR=. and:

java -cp ./lib/* [...]

Which is exactly what you want. It works with migrate.sh (no prefix, 
BIN_DIR=.), ./migrate.sh (BIN_DIR=.), /usr/local/foo/migrate.sh 
(BIN_DIR=/usr/local/foo), etc.

No 'cd' required at all. 50% reduction in lines of code.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Dec 11, 2020, 21:34 Christopher Schultz <
chris@christopherschultz.net> wrote:

> Rainer,
>
> On 12/11/20 14:19, Rainer Jung wrote:
> > Hi Chris,
> >
> > Am 11.12.2020 um 19:53 schrieb Christopher Schultz:
> >> Rainer,
> >>
> >> On 12/11/20 06:19, Rainer Jung wrote:
> >>> Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
> >>>> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <
> mgrigorov@apache.org>
> >>>> wrote:
> >>>>
> >>>>> Hi Rainer,
> >>>>>
> >>>>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <
> rainer.jung@kippdata.de>
> >>>>> wrote:
> >>>>>
> >>>>>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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"
> >>
> >> I would avoid using "cd" in a script if at all possible. The migration
> >> tool should be able to be run from anywhere with command-line
> >> arguments to anything you need to call (e.g. java -cp).
> >
> > What risk do you see in the two "cd" uses? How is the ability to be
> > called from anywhere reduced by teh above construct? It was actually
> > introduced to myke it callable from anywhere.
>
> The whole script can be:
>
> BIN_FOLDER=$( dirname ${0} )
> java -cp "$BIN_FOLDER/../lib/*" org.apache.tomcat.jakartaee.MigrationCLI
> "$@"
>
> The "cd" is not necessary at all and IMO is just more complicated.
>
> Note that the "-cp" won't work because the files must be separated by :
> on *NIX. Unless I don't know how to build this in Maven (which is weird,
> I have no mvnw command to run, so I did "mvn verify" which did build a
> .jar file), there won't be any lib directory to include.
>
> Don't we really just want:
>
> BIN_FOLDER=$( dirname ${0} )
> java -jar "$BIN_FOLDER/target/jakartaee-migration-0.1.0.jar" \
>    org.apache.tomcat.jakartaee.MigrationCLI "$@"
>
> ?
>
> Maybe I just don't understand what this script is intended to
> accomplish. A shortcut for "java -jar [migration-tool]" or something else?
>
> Every Java-related shell script I ever write looks something like this:
>
> #/bin/sh
> BIN_DIR=$( dirname ${0} )
>

dirname just cuts the parent path segment.
If there is no such then it returns '.'
Play with it and see.

CLASSPATH=
> for jar in $BIN_DIR/lib/*.jar ; do
>    CLASSPATH="${CLASSPATH}:${jar}"
> fi
>
> java -cp "$CLASSPATH" ${JAVA_OPTS} ${MAIN_CLASS} "$@"
>
> It always works from anywhere, and anything "$@" expands to is always
> relative to the user's current working directory, exactly like they expect.
>
> If you need to know what BIN_DIR is inside the Java process, then:
>
> java -cp "$CLASSPATH" -Dbase.dir="${BIN_DIR}" ${JAVA_OPTS} \
>     ${MAIN_CLASS} "$@"
>
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Rainer,

On 12/11/20 14:19, Rainer Jung wrote:
> Hi Chris,
> 
> Am 11.12.2020 um 19:53 schrieb Christopher Schultz:
>> Rainer,
>>
>> On 12/11/20 06:19, Rainer Jung wrote:
>>> Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
>>>> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
>>>> wrote:
>>>>
>>>>> Hi Rainer,
>>>>>
>>>>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
>>>>> wrote:
>>>>>
>>>>>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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"
>>
>> I would avoid using "cd" in a script if at all possible. The migration 
>> tool should be able to be run from anywhere with command-line 
>> arguments to anything you need to call (e.g. java -cp).
> 
> What risk do you see in the two "cd" uses? How is the ability to be 
> called from anywhere reduced by teh above construct? It was actually 
> introduced to myke it callable from anywhere.

The whole script can be:

BIN_FOLDER=$( dirname ${0} )
java -cp "$BIN_FOLDER/../lib/*" org.apache.tomcat.jakartaee.MigrationCLI 
"$@"

The "cd" is not necessary at all and IMO is just more complicated.

Note that the "-cp" won't work because the files must be separated by : 
on *NIX. Unless I don't know how to build this in Maven (which is weird, 
I have no mvnw command to run, so I did "mvn verify" which did build a 
.jar file), there won't be any lib directory to include.

Don't we really just want:

BIN_FOLDER=$( dirname ${0} )
java -jar "$BIN_FOLDER/target/jakartaee-migration-0.1.0.jar" \
   org.apache.tomcat.jakartaee.MigrationCLI "$@"

?

Maybe I just don't understand what this script is intended to 
accomplish. A shortcut for "java -jar [migration-tool]" or something else?

Every Java-related shell script I ever write looks something like this:

#/bin/sh
BIN_DIR=$( dirname ${0} )
CLASSPATH=
for jar in $BIN_DIR/lib/*.jar ; do
   CLASSPATH="${CLASSPATH}:${jar}"
fi

java -cp "$CLASSPATH" ${JAVA_OPTS} ${MAIN_CLASS} "$@"

It always works from anywhere, and anything "$@" expands to is always 
relative to the user's current working directory, exactly like they expect.

If you need to know what BIN_DIR is inside the Java process, then:

java -cp "$CLASSPATH" -Dbase.dir="${BIN_DIR}" ${JAVA_OPTS} \
    ${MAIN_CLASS} "$@"

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Chris,

Am 11.12.2020 um 19:53 schrieb Christopher Schultz:
> Rainer,
> 
> On 12/11/20 06:19, Rainer Jung wrote:
>> Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
>>> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
>>> wrote:
>>>
>>>> Hi Rainer,
>>>>
>>>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
>>>> wrote:
>>>>
>>>>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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"
> 
> I would avoid using "cd" in a script if at all possible. The migration 
> tool should be able to be run from anywhere with command-line arguments 
> to anything you need to call (e.g. java -cp).

What risk do you see in the two "cd" uses? How is the ability to be 
called from anywhere reduced by teh above construct? It was actually 
introduced to myke it callable from anywhere.

Best regards,

Rainer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Rainer,

On 12/11/20 06:19, Rainer Jung wrote:
> Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
>> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
>> wrote:
>>
>>> Hi Rainer,
>>>
>>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
>>> wrote:
>>>
>>>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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"

I would avoid using "cd" in a script if at all possible. The migration 
tool should be able to be run from anywhere with command-line arguments 
to anything you need to call (e.g. java -cp).

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Dec 11, 2020 at 1:20 PM Rainer Jung <ra...@kippdata.de> wrote:

> Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
> > On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
> > wrote:
> >
> >> Hi Rainer,
> >>
> >> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
> >> wrote:
> >>
> >>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Rainer Jung <ra...@kippdata.de>.
Am 11.12.2020 um 09:49 schrieb Martin Grigorov:
> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
> wrote:
> 
>> Hi Rainer,
>>
>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
>> wrote:
>>
>>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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"

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Martin,

On 12/11/20 04:02, Martin Grigorov wrote:
> On Fri, Dec 11, 2020 at 10:53 AM Mark Thomas <ma...@apache.org> wrote:
> 
>> On 11/12/2020 08:49, Martin Grigorov wrote:
>>> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
>>> wrote:
>>>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
>>
>> <snip/>
>>
>>>>> 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
>>
>> You might find inspiration for a fix in the Tomcat startup scripts.
>>
> 
> Do we need to fix it ? It works fine.

This looks weird to me:

 > BIN_FOLDER=`dirname $PWD/$0`

Why not simply:

BIN_FOLDER=$( dirname $0 )

(I have converted to $(...) instead of `...` because the syntax is 
better, more navigable, allows nesting, etc.)

There shouldn't be any reason for the $PWD to be in there because the 
user's current working directory is irrelevant.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Dec 11, 2020 at 10:53 AM Mark Thomas <ma...@apache.org> wrote:

> On 11/12/2020 08:49, Martin Grigorov wrote:
> > On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
> > wrote:
> >> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
>
> <snip/>
>
> >>> 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
>
> You might find inspiration for a fix in the Tomcat startup scripts.
>

Do we need to fix it ? It works fine.


>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Mark Thomas <ma...@apache.org>.
On 11/12/2020 08:49, Martin Grigorov wrote:
> On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
> wrote:
>> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>

<snip/>

>>> 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

You might find inspiration for a fix in the Tomcat startup scripts.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Dec 11, 2020 at 10:41 AM Martin Grigorov <mg...@apache.org>
wrote:

> Hi Rainer,
>
> On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
> wrote:
>
>> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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


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

Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Martin Grigorov <mg...@apache.org>.
Hi Rainer,

On Fri, Dec 11, 2020 at 10:37 AM Rainer Jung <ra...@kippdata.de>
wrote:

> Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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`
>
> Regards,
>
> Rainer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat-jakartaee-migration] branch master updated: Make migrate.sh usable from any directory

Posted by Rainer Jung <ra...@kippdata.de>.
Am 11.12.2020 um 08:25 schrieb mgrigorov@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 <mg...@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?

Maybe one could

   cd `dirname $0`

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org