Antti Karanta | 1 Sep 11:45 2005
Picon

RE: Getting the exit status of another Groovy script


> > On 22/08/05, Antti Karanta <antti.karanta@...> wrote:
> 
> > > C:\Temp>groovy -e "def p='cmd /c groovy
> > > exc.groovy'.execute();p.waitFor();println p.exitValue()"
> > > 0
> > > 
> > > C:\Temp>groovy -e "def p='groovy
> > > exc.groovy'.execute();p.waitFor();println p.exitValue()"
> > > Caught: java.io.IOException: CreateProcess: groovy 
> > exc.groovy error=2
> > 
> > So it meanse cmd returns 0 because the shell command succeeds to
> > execute your script? And we don't get the return value of 
> the script?
> 
>   That's my theory. If anybody knows any better feel free to comment.
> 
> 
>   I was wondering about why I wan't able to execute the groovy script
> w/out cmd /c, so I tried the same thing w/ perl and ruby:
> 
> C:\Temp>ruby -e "system('groovy exc.groovy');puts $?"
> -1
> 
> C:\Temp>perl -e "system('groovy exc.groovy');print $?"
> moi!
> 0
> C:\Temp>

(Continue reading)

Guillaume Laforge | 1 Sep 11:53 2005
Picon

Re: Getting the exit status of another Groovy script

Hello Antti,

First of all, thanks a lot for exploring that topic in depth! Well done!

See my comment below...

On 01/09/05, Antti Karanta <antti.karanta@...> wrote:
> [...]
>   I inspected this further and found out that the perl version will get
> the correct exit status if the following line is added as the last line
> of groovy.bat:
> 
> exit %ERROR_LEVEL%
> 
>   This seems to indicate that different programs find out the exit
> status of a program they run in a different fashion.
> [...]
>   I have no idea why perl gets the exit status wrong and ruby gets it
> right w/ the current version of groovy.bat. However, would it be a good
> idea to include the above mentioned line in groovy.bat in the next
> release of groovy as it seems to correct the problem? Is anyone aware of
> any negative consequences of adding this line?

Jochen's just improved our current scripts, both .sh and .bat, and we
even got rid of classworlds. I don't think the new scripts include
that exit %ERROR_LEVEL% line, but I believe it's a nice and welcome
addition. I don't see any negative consequence at the moment, but
since I'm not a .bat script guru...

Could you please create a JIRA issue (if there's none already yet) and
(Continue reading)

Antti Karanta | 1 Sep 12:23 2005
Picon

RE: Getting the exit status of another Groovy script


> > perl -e "system('groovy -e \"System.exit(1)\"');print $?>>8"
> 
> > ruby -e "system('groovy -e \"System.exit(1)\"');print $?"

  I just noticed that the ruby version has not been working at all -
it's exit status is due to ruby not finding the groovy interpreter. The
perl version works correctly, though. This is the corrected ruby
version:

> ruby -e "system('groovy.bat -e \"System.exit(1)\"');print $?>>8"
  (added the .bat and the bit shift)

  So, neither perl nor ruby are getting the exit status right unless the
line exit %ERROR_LEVEL% is added to groovy.bat. 

> Is anyone aware of any negative consequences of adding this line?
> exit %ERROR_LEVEL%

  I just noticed that adding this line causes the commend prompt to exit
after running groovy directly. = ( So this is of no use...

  So I guess I did not get much further w/ this...

     -Antti-


Antti Karanta | 1 Sep 12:46 2005
Picon

RE: Getting the exit status of another Groovy script


> > > perl -e "system('groovy -e \"System.exit(1)\"');print $?>>8"
> > 
> > > ruby -e "system('groovy -e \"System.exit(1)\"');print $?"
> 
>   I just noticed that the ruby version has not been working at all -
> it's exit status is due to ruby not finding the groovy 
> interpreter. The
> perl version works correctly, though. This is the corrected ruby
> version:
> 
> > ruby -e "system('groovy.bat -e \"System.exit(1)\"');print $?>>8"
>   (added the .bat and the bit shift)

  I just realized that by adding the .bat the groovy version runs, too:

> groovy -e "p='groovy.bat -e
\"System.exit(1)\"'.execute();p.waitFor();println p.exitValue()"

  But it has the same issue w/ the exit status. It seems the exit status
of running a groovy script is simply not available.

  I can solve my immediate problems by copying groovy.bat to a different
name, adding exit %ERROR_LEVEL% to that file and running it when I need
to run groovy from within other scripts and getting the right exit
status. It would be nice if there was a cleaner solution for this. I'm
out of ideas...

     -Antti-

(Continue reading)

phkim | 1 Sep 12:53 2005
Picon

Re: Question about matchers from the new tutorial...

On Wed, Aug 31, 2005 at 01:53:51PM -0500, Thomas R. Corbin wrote:
> 
> It's a silly little question, but I'm trying to swap green and blue on an 
> icon, so I thought I'd write a little groovy program to do it.   In the end, 
> I used emacs macros, but I'm still wondering what I'm doing wrong with the 
> regular expression - I end up having to use:
> 
> matcher[0][1]

Please check the issue:
http://jira.codehaus.org/browse/GROOVY-1000

Kim

> 
> instead of:
> 
> matcher[1]
> 
> The tutorial doesn't end up doing that, and I assume my regular expression is 
> making me do it, but I'm not sure why.
> 

Thomas R. Corbin | 1 Sep 15:06 2005

Re: Question about matchers from the new tutorial...

On Thursday, 01 September 2005 05:53 am, phkim@... wrote:
> On Wed, Aug 31, 2005 at 01:53:51PM -0500, Thomas R. Corbin wrote:
> > It's a silly little question, but I'm trying to swap green and blue on an
> > icon, so I thought I'd write a little groovy program to do it.   In the
> > end, I used emacs macros, but I'm still wondering what I'm doing wrong
> > with the regular expression - I end up having to use:
> >
> > matcher[0][1]
>
> Please check the issue:
> http://jira.codehaus.org/browse/GROOVY-1000
>
> Kim
>
> > instead of:
> >
> > matcher[1]
> >
> > The tutorial doesn't end up doing that, and I assume my regular
> > expression is making me do it, but I'm not sure why.

	I guess I don't understand.   In your example,

Now matcher[index] is either a matched String or a List of matched group 
Strings  at the position of the given index. 
 For an example, 

     def matcher = "\$abc." =~ /\$(.*)\./ 
     assert "\\\$(.*)\\." == /\$(.*)\./ 
     // assert matcher[1] == "abc" // This has worked before jsr-03-release 
(Continue reading)

Thomas R. Corbin | 1 Sep 15:18 2005

Re: Question about matchers from the new tutorial...

On Thursday, 01 September 2005 05:53 am, phkim@... wrote:
> On Wed, Aug 31, 2005 at 01:53:51PM -0500, Thomas R. Corbin wrote:
> > It's a silly little question, but I'm trying to swap green and blue on an
> > icon, so I thought I'd write a little groovy program to do it.   In the
> > end, I used emacs macros, but I'm still wondering what I'm doing wrong
> > with the regular expression - I end up having to use:
> >
> > matcher[0][1]
>
> Please check the issue:
> http://jira.codehaus.org/browse/GROOVY-1000

	So it looks like the tutorial has to change, then.

	In your explanation, you say that either a matched String or a List of 
matched group Strings  at the position of the given index will be returned.

	Is there way to predict which will be returned?

	Do we always need to somehow test the returned value to determine how to 
handle it?

 
>
> Kim
>
> > instead of:
> >
> > matcher[1]
> >
(Continue reading)

Picon

dictionaries

hello,
I would like to know what is the type definition for a dictionary...
we can write for instance for an array :
    def myArray = [1776, -1, 33, 99, 0, 928734928763];
or
    int[]  myArray = [1776, -1, 33, 99, 0, 928734928763];

for a dictionary we have :
   def scores = [ "Brett":100, "Pete":"Did not finish", "Andrew":86.87934 ];
or
    ?   scores = [ "Brett":100, "Pete":"Did not finish", 
"Andrew":86.87934 ];

What could be "?" ? I would like to have in information like : 
map<String,String> for instance

regards
Xavier

Guillaume Laforge | 1 Sep 16:56 2005
Picon

Re: dictionaries

Hello Xavier,

On 01/09/05, xavier.mehaut@...
<xavier.mehaut@...> wrote:
> I would like to know what is the type definition for a dictionary...
> we can write for instance for an array :
>     def myArray = [1776, -1, 33, 99, 0, 928734928763];
> or
>     int[]  myArray = [1776, -1, 33, 99, 0, 928734928763];
> 
> for a dictionary we have :
>    def scores = [ "Brett":100, "Pete":"Did not finish", "Andrew":86.87934 ];
> or
>     ?   scores = [ "Brett":100, "Pete":"Did not finish",
> "Andrew":86.87934 ];
> 
> What could be "?" ? I would like to have in information like :
> map<String,String> for instance

At the moment, it's a mere HashMap, so you can say:

Map scores =  [ "Brett":100, "Pete":"Did not finish", "Andrew":86.87934 ]

But it's just a Map<Object, Object>, we don't enforce types there.

--

-- 
Guillaume Laforge
http://glaforge.free.fr/blog/groovy

(Continue reading)

Hein Meling | 1 Sep 16:58 2005
Picon

Re: dictionaries

It would be Map.  You cannot use generics in groovy, at least not yet.

Hein

On Thu, 2005-09-01 at 16:52 +0200, xavier.mehaut@... wrote:
> hello,
> I would like to know what is the type definition for a dictionary...
> we can write for instance for an array :
>     def myArray = [1776, -1, 33, 99, 0, 928734928763];
> or
>     int[]  myArray = [1776, -1, 33, 99, 0, 928734928763];
> 
> for a dictionary we have :
>    def scores = [ "Brett":100, "Pete":"Did not finish", "Andrew":86.87934 ];
> or
>     ?   scores = [ "Brett":100, "Pete":"Did not finish", 
> "Andrew":86.87934 ];
> 
> What could be "?" ? I would like to have in information like : 
> map<String,String> for instance
> 
> regards
> Xavier
> 
> 


Gmane