geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r567829 - /geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Date Mon, 20 Aug 2007 21:09:54 GMT
Author: jdillon
Date: Mon Aug 20 14:09:53 2007
New Revision: 567829

URL: http://svn.apache.org/viewvc?rev=567829&view=rev
Log:
Release logging muck and flush io bits on exit

Modified:
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=567829&r1=567828&r2=567829&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Mon Aug 20 14:09:53 2007
@@ -217,14 +217,25 @@
             interactive = false;
         }
 
-        execute(line.getArgs());
+        int code;
+        
+        try {
+            code = execute(line.getArgs());
+        }
+        finally {
+            LogFactory.releaseAll();
+            
+            io.flush();
+        }
+        
+        System.exit(code);
     }
 
-    private void execute(final String[] args) throws Exception {
+    private int execute(final String[] args) throws Exception {
         // Its okay to use logging now
         Log log = LogFactory.getLog(Main.class);
         boolean debug = log.isDebugEnabled();
-
+        
         //
         // TODO: Need to pass Shell the ClassWorld, so that the application can add to it
if needed
         //
@@ -256,7 +267,7 @@
         //
         // TODO: Pass interactive flags (maybe as property) so gshell knows what mode it
is
         //
-        
+
         if (commands != null) {
             gshell.execute(commands);
         }
@@ -290,12 +301,17 @@
         }
 
         // If the result is a number, then pass that back to the calling shell
+        int code = 0;
+        
         if (result instanceof Number) {
-            System.exit(((Number)result).intValue());
+            code = ((Number)result).intValue();
         }
-        else {
-            System.exit(0);
+        
+        if (debug) {
+            log.debug("Exiting with code: " + code);
         }
+        
+        return code;
     }
 
     //



Mime
View raw message