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 2017/01/28 17:08:22 UTC

karaf git commit: [KARAF-4835] Use URI in shell:source to get completion

Repository: karaf
Updated Branches:
  refs/heads/master f47a22434 -> 21769793c


[KARAF-4835] Use URI in shell:source to get completion


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/21769793
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/21769793
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/21769793

Branch: refs/heads/master
Commit: 21769793c93257429576ffcd4c69ae94e602194c
Parents: f47a224
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Sat Jan 28 18:07:48 2017 +0100
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Sat Jan 28 18:07:48 2017 +0100

----------------------------------------------------------------------
 .../apache/karaf/shell/commands/impl/SourceAction.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/21769793/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
index c8bae6f..b1bf564 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
@@ -25,6 +25,7 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.List;
 
@@ -47,7 +48,7 @@ public class SourceAction implements Action {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Argument(index = 0, name = "script", description = "A URI pointing to the script", required = true, multiValued = false)
-    private String script;
+    private URI script;
 
     @Argument(index = 1, name = "args", description = "Arguments for the script", required = false, multiValued = true)
     private List<Object> args;
@@ -60,15 +61,14 @@ public class SourceAction implements Action {
         BufferedReader reader = null;
         Object arg0 = session.get("0");
         try {
-            // First try a URL
             try {
-                URL url = new URL(script);
+                URL url = script.toURL();
                 log.info("Printing URL: " + url);
                 reader = new BufferedReader(new InputStreamReader(url.openStream()));
             }
             catch (MalformedURLException ignore) {
-                // They try a file
-                File file = new File(script);
+                // fallback to a file
+                File file = new File(script.getPath());
                 log.info("Printing file: " + file);
                 reader = new BufferedReader(new FileReader(file));
             }