Permalink
Browse files

Jline should read the default /etc/inputrc if no user defined configu…

…ration is available

This should fix issue #45
  • Loading branch information...
1 parent 5acfe59 commit e0e9465e5682637f117780d124933c1d81b4c178 @gnodet gnodet committed Jun 11, 2012
Showing with 17 additions and 3 deletions.
  1. +17 −3 src/main/java/jline/console/ConsoleReader.java
@@ -76,6 +76,8 @@
public static final String INPUT_RC = ".inputrc";
+ public static final String DEFAULT_INPUT_RC = "/etc/inputrc";
+
public static final char BACKSPACE = '\b';
public static final char RESET_LINE = '\r';
@@ -209,12 +211,24 @@ public ConsoleReader(final @Nullable String appName, final InputStream in, final
this.out = new OutputStreamWriter(terminal.wrapOutIfNeeded(out), this.encoding);
setInput( in );
- this.inputrcUrl = Urls.create(Configuration.getString(JLINE_INPUTRC,
- Urls.create(new File(Configuration.getUserHome(), INPUT_RC)).toExternalForm()));
-
+ this.inputrcUrl = getInputRc();
+
consoleKeys = new ConsoleKeys(appName, inputrcUrl);
}
+ private URL getInputRc() throws IOException {
+ String path = Configuration.getString(JLINE_INPUTRC);
+ if (path == null) {
+ File f = new File(Configuration.getUserHome(), INPUT_RC);
+ if (!f.exists()) {
+ f = new File(DEFAULT_INPUT_RC);
+ }
+ return f.toURI().toURL();
+ } else {
+ return Urls.create(path);
+ }
+ }
+
public KeyMap getKeys() {
return consoleKeys.getKeys();
}

0 comments on commit e0e9465

Please sign in to comment.