Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

GRAILS-9279 only configure persistence in the History instance if the…

… history file is writeable
  • Loading branch information...
commit 53c9e705270cfc4dcd05740f588b95564d3faf06 1 parent adbb6cb
Burt Beckwith authored
View
13 grails-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java
@@ -51,7 +51,7 @@
public class GrailsConsole {
private static GrailsConsole instance;
-
+
public static final String ENABLE_TERMINAL = "grails.console.enable.terminal";
public static final String ENABLE_INTERACTIVE = "grails.console.enable.interactive";
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
@@ -138,7 +138,9 @@ protected GrailsConsole() throws IOException {
}
history = prepareHistory();
- reader.setHistory(history);
+ if (history != null) {
+ reader.setHistory(history);
+ }
}
else if (isActivateTerminal()) {
terminal = createTerminal();
@@ -155,7 +157,7 @@ private boolean isInteractiveEnabled() {
}
private boolean isActivateTerminal() {
- return readPropOrTrue(ENABLE_TERMINAL);
+ return readPropOrTrue(ENABLE_TERMINAL);
}
private boolean readPropOrTrue(String prop) {
@@ -200,9 +202,8 @@ public boolean isANSISupported() {
* will live in the home directory of the user.
*/
protected History prepareHistory() throws IOException {
- String historyFile = System.getProperty("user.home") + File.separator + HISTORYFILE;
- history = new History(new File(historyFile));
- return history;
+ File file = new File(System.getProperty("user.home"), HISTORYFILE);
+ return file.canWrite() ? new History(file) : null;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.