Browse Source

Use appropriate methods in exec plugin.

pull/118/head
Greg Holmes 9 years ago
parent
commit
ba4fc8b86a
1 changed files with 10 additions and 9 deletions
  1. 10
    9
      exec/src/com/dmdirc/addons/exec/ExecCommand.java

+ 10
- 9
exec/src/com/dmdirc/addons/exec/ExecCommand.java View File

@@ -84,13 +84,14 @@ public class ExecCommand extends Command {
84 84
                         "Could not execute: " + commandArray[0] + " does not exist.");
85 85
             } else {
86 86
                 final Process p = Runtime.getRuntime().exec(commandArray);
87
-                final List<String> execOutput = args.isSilent()
88
-                        ? null : new LinkedList<String>();
89
-                final List<String> errorOutput = args.isSilent()
90
-                        ? null : new LinkedList<String>();
91
-                StreamUtils.readStreamIntoList(p.getInputStream(), execOutput);
92
-                StreamUtils.readStreamIntoList(p.getErrorStream(), errorOutput);
93
-                if (!args.isSilent()) {
87
+                if (args.isSilent()) {
88
+                    StreamUtils.readStream(p.getInputStream());
89
+                    StreamUtils.readStream(p.getErrorStream());
90
+                } else {
91
+                    final List<String> execOutput = new LinkedList<>();
92
+                    final List<String> errorOutput = new LinkedList<>();
93
+                    StreamUtils.readStreamIntoList(p.getInputStream(), execOutput);
94
+                    StreamUtils.readStreamIntoList(p.getErrorStream(), errorOutput);
94 95
                     for (String line : execOutput) {
95 96
                         sendLine(origin, args.isSilent(), FORMAT_OUTPUT, line);
96 97
                     }
@@ -100,8 +101,8 @@ public class ExecCommand extends Command {
100 101
                 }
101 102
             }
102 103
         } catch (IOException ex) {
103
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex, "Unable to run application: "
104
-                    + ex.getMessage(), ""));
104
+            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
105
+                    "Unable to run application: " + ex.getMessage(), ""));
105 106
         }
106 107
     }
107 108
 

Loading…
Cancel
Save