You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2021/05/06 09:00:22 UTC

[karaf] branch karaf-4.2.x updated: [KARAF-7133] Allow karaf commands to have return codes

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new 31b2f50  [KARAF-7133] Allow karaf commands to have return codes
31b2f50 is described below

commit 31b2f50f94dcb034baa7ae22d2112cd965358069
Author: Johannes Utzig <j....@seeburger.de>
AuthorDate: Thu Apr 1 11:59:53 2021 +0200

    [KARAF-7133] Allow karaf commands to have return codes
    
    only print out results if they are not integers. If they are integers,
    they should are treated as exit codes.
    
    (cherry picked from commit c9b5c343d0ad5c0e1fc7b95b14b79ef748908821)
---
 .../java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index b4af472..9878f07 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -465,7 +465,7 @@ public class ConsoleSessionImpl implements Session {
     private void doExecute(CharSequence command) {
         try {
             Object result = session.execute(command);
-            if (result != null) {
+            if (result != null && !(result instanceof Integer)) {
                 session.getConsole().println(session.format(result, Converter.INSPECT));
             }
         } catch (InterruptedException e) {