You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2015/12/31 15:09:51 UTC
sqoop git commit: SQOOP-2764: Sqoop2: Sqoop shell history is no
longer working
Repository: sqoop
Updated Branches:
refs/heads/sqoop2 8d63df714 -> 008b12693
SQOOP-2764: Sqoop2: Sqoop shell history is no longer working
(Dian Fu via Jarek Jarcec Cecho)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/008b1269
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/008b1269
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/008b1269
Branch: refs/heads/sqoop2
Commit: 008b1269321a5dbe00336fdf18a161d42e36de0c
Parents: 8d63df7
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Thu Dec 31 06:09:12 2015 -0800
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Thu Dec 31 06:09:12 2015 -0800
----------------------------------------------------------------------
.../java/org/apache/sqoop/shell/SqoopShell.java | 24 +++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/008b1269/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java b/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java
index 7e4a7df..4aabfcc 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/SqoopShell.java
@@ -22,6 +22,9 @@ import java.nio.charset.Charset;
import java.util.HashSet;
import java.util.Iterator;
+import jline.console.history.History;
+import jline.console.history.PersistentHistory;
+
import org.apache.sqoop.shell.core.Constants;
import org.apache.sqoop.shell.utils.ThrowableDisplayer;
import org.codehaus.groovy.runtime.MethodClosure;
@@ -56,8 +59,8 @@ public final class SqoopShell {
static {
commandsToKeep = new HashSet<String>();
- commandsToKeep.add("exit");
- commandsToKeep.add("history");
+ commandsToKeep.add(":exit");
+ commandsToKeep.add(":history");
}
/**
@@ -68,11 +71,26 @@ public final class SqoopShell {
*/
public static void main (String[] args) throws Exception {
System.setProperty("groovysh.prompt", Constants.SQOOP_PROMPT);
- Groovysh shell = new Groovysh();
+ final Groovysh shell = new Groovysh();
// Install our error hook (exception handling)
shell.setErrorHook(new MethodClosure(ThrowableDisplayer.class, "errorHook"));
+ // Install shutdown hook
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ History history = shell.getRunner().getReader().getHistory();
+ if (history instanceof PersistentHistory) {
+ try {
+ ((PersistentHistory)history).flush();
+ } catch (IOException e) {
+ // Ignore this exception as it only affects history
+ }
+ }
+ }
+ });
+
CommandRegistry registry = shell.getRegistry();
@SuppressWarnings("unchecked")
Iterator<Command> iterator = registry.iterator();