This is an automated email from the ASF dual-hosted git repository.

andor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new a3c478bca8 ZOOKEEPER-5022: Added "exit" command to zkCli.sh
a3c478bca8 is described below

commit a3c478bca888cb990001ccbfdb0256f2d2243360
Author: Dávid Paksy <[email protected]>
AuthorDate: Wed Apr 15 01:47:53 2026 +0200

    ZOOKEEPER-5022: Added "exit" command to zkCli.sh
    
    Reviewers: anmolnar, ctubbsii
    Author: PDavid
    Closes #2358 from PDavid/ZOOKEEPER-5022-cli-exit-cmd
---
 .../src/main/resources/markdown/zookeeperCLI.md    |  5 ++--
 .../java/org/apache/zookeeper/ZooKeeperMain.java   | 31 ++++++++++++++--------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/zookeeper-docs/src/main/resources/markdown/zookeeperCLI.md 
b/zookeeper-docs/src/main/resources/markdown/zookeeperCLI.md
index 7096aa0cc8..aeccf1dcfc 100644
--- a/zookeeper-docs/src/main/resources/markdown/zookeeperCLI.md
+++ b/zookeeper-docs/src/main/resources/markdown/zookeeperCLI.md
@@ -45,6 +45,7 @@ ZooKeeper -server host:port cmd args
        delete [-v version] path
        deleteall path
        delquota [-n|-b|-N|-B] path
+       exit
        get [-s] [-w] path
        getAcl [-s] path
        getAllChildrenNumber path
@@ -345,8 +346,8 @@ A switch to turn on/off whether printing watches or not.
        printwatches is on
 ```
 
-## quit
-Quit the CLI windows.
+## quit (or exit)
+The `quit` or `exit` command can be used to quit the CLI windows.
 
 ```bash
 [zkshell: 1] quit
diff --git 
a/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeperMain.java 
b/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeperMain.java
index d5ffc20ca5..6b469fec83 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeperMain.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeperMain.java
@@ -77,12 +77,21 @@ public boolean getPrintWatches() {
         return printWatches;
     }
 
+    private static final String CMD_CONNECT = "connect";
+    private static final String CMD_HISTORY = "history";
+    private static final String CMD_REDO = "redo";
+    private static final String CMD_QUIT = "quit";
+    private static final String CMD_EXIT = "exit";
+    private static final String CMD_PRINT_WATCHES = "printwatches";
+
+
     static {
-        commandMap.put("connect", "host:port");
-        commandMap.put("history", "");
-        commandMap.put("redo", "cmdno");
-        commandMap.put("printwatches", "on|off");
-        commandMap.put("quit", "");
+        commandMap.put(CMD_CONNECT, "host:port");
+        commandMap.put(CMD_HISTORY, "");
+        commandMap.put(CMD_REDO, "cmdno");
+        commandMap.put(CMD_PRINT_WATCHES, "on|off");
+        commandMap.put(CMD_QUIT, "");
+        commandMap.put(CMD_EXIT, "");
         Stream.of(CommandFactory.Command.values())
             .map(command -> CommandFactory.getInstance(command))
             // add all commands to commandMapCli and commandMap
@@ -411,34 +420,34 @@ protected boolean processZKCmd(MyCommandOptions co) 
throws CliException, IOExcep
 
         LOG.debug("Processing {}", cmd);
 
-        if (cmd.equals("quit")) {
+        if (cmd.equals(CMD_QUIT) || cmd.equals(CMD_EXIT)) {
             zk.close();
             ServiceUtils.requestSystemExit(exitCode);
-        } else if (cmd.equals("redo") && args.length >= 2) {
+        } else if (cmd.equals(CMD_REDO) && args.length >= 2) {
             Integer i = Integer.decode(args[1]);
             if (commandCount <= i || i < 0) { // don't allow redoing this redo
                 throw new MalformedCommandException("Command index out of 
range");
             }
             cl.parseCommand(history.get(i));
-            if (cl.getCommand().equals("redo")) {
+            if (cl.getCommand().equals(CMD_REDO)) {
                 throw new MalformedCommandException("No redoing redos");
             }
             history.put(commandCount, history.get(i));
             processCmd(cl);
-        } else if (cmd.equals("history")) {
+        } else if (cmd.equals(CMD_HISTORY)) {
             for (int i = commandCount - 10; i <= commandCount; ++i) {
                 if (i < 0) {
                     continue;
                 }
                 System.out.println(i + " - " + history.get(i));
             }
-        } else if (cmd.equals("printwatches")) {
+        } else if (cmd.equals(CMD_PRINT_WATCHES)) {
             if (args.length == 1) {
                 System.out.println("printwatches is " + (printWatches ? "on" : 
"off"));
             } else {
                 printWatches = args[1].equals("on");
             }
-        } else if (cmd.equals("connect")) {
+        } else if (cmd.equals(CMD_CONNECT)) {
             if (args.length >= 2) {
                 connectToZK(args[1]);
             } else {

Reply via email to