You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Edward Ribeiro (JIRA)" <ji...@apache.org> on 2012/12/26 22:02:12 UTC

[jira] [Commented] (ZOOKEEPER-1535) ZK Shell/Cli re-executes last command on exit

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-1535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13539690#comment-13539690 ] 

Edward Ribeiro commented on ZOOKEEPER-1535:
-------------------------------------------

I have looked into this issue and it's related to the lines 347-348 of the run() method in file ZooKeeperMain.java:

{noformat}
   boolean watch = processCmd(cl);
   if (!watch) {
      System.exit(0);
   }
{noformat}

The REPL is executed in a "while ((line = (...)) != null)" loop. Therefore when the user issue <ctrl+d> the flow jumps out of loop, but before ending execution it runs the code above, that seems redundant, imo. 

The issue shows up because the "cl" object still points to the last executed command even though the "line" variable (that  populates the "cl" object) is already null. Looking at svn logs and studying the control flow, it looks like the this snippet  lost its usefulness during successive code modifications (last one that affected it: ZOOKEEPER-82), because its job is already done by executeLine() calls in the loop.

My suggestion would be to get rid of this code block, but I would like to hear what you think about it. There's any situation where this snippet would be relevant?
                
> ZK Shell/Cli re-executes last command on exit
> ---------------------------------------------
>
>                 Key: ZOOKEEPER-1535
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1535
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: scripts
>         Environment: zookeeper-3.4.3 release
>            Reporter: Stu Hood
>              Labels: cli, shell, zkcli, zkcli.sh
>
> In the ZK 3.4.3 release's version of zkCli.sh, the last command that was executed is *re*-executed when you {{ctrl+d}} out of the shell. In the snippet below, {{ls}} is executed, and then {{ctrl+d}} is triggered (inserted below to illustrate), the output from {{ls}} appears again, due to the command being re-run. 
> {noformat}
> [zk: zookeeper.example.com:2181(CONNECTED) 0] ls /blah
> [foo]
> [zk: zookeeper.example.com:2181(CONNECTED) 1] <ctrl+d> [foo]
> $
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira