Skip to content

Commit

Permalink
ConsoleEngineImpl: fix potential NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Dec 16, 2021
1 parent 771f221 commit 7ae2b8b
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import org.jline.terminal.Terminal;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.Log;
import org.jline.utils.OSUtils;

/**
* Manage console variables, commands and script execution.
Expand Down Expand Up @@ -112,6 +114,10 @@ public ConsoleEngineImpl(Set<Command> commands, ScriptEngine engine, Printer pri
aliasFile = configPath.getUserConfig("aliases.json");
if (aliasFile == null) {
aliasFile = configPath.getUserConfig("aliases.json", true);
if (aliasFile == null) {
Log.warn("Failed to write in user config path!");
aliasFile = OSUtils.IS_WINDOWS ? Paths.get("NUL") : Paths.get("/dev/null");
}
persist(aliasFile, aliases);
} else {
aliases.putAll((Map<String,String>)slurp(aliasFile));
Expand Down

0 comments on commit 7ae2b8b

Please sign in to comment.