Patchwork [BUG:1300] cli: Fix issues in non readline mode

login
register
Submitter Vijay Bellur
Date 2010-08-19 17:20:08
Message ID <20100819172008.GA5072@dev.gluster.com>
Download mbox | patch
Permalink /patch/4217/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Vijay Bellur - 2010-08-19 17:20:08
Signed-off by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Vijay Bellur <vijay@gluster.com>
---
 cli/src/input.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/cli/src/input.c b/cli/src/input.c
index 8bfe14d..e762fbd 100644
--- a/cli/src/input.c
+++ b/cli/src/input.c
@@ -56,17 +56,19 @@  cli_input (void *d)
         int               ret = 0;
         char              cmdbuf[CMDBUFSIZ];
         char             *cmd = NULL;
+        size_t            len = 0;
 
         state = d;
 
         for (;;) {
-                cli_out ("%s", state->prompt);
+                printf ("%s", state->prompt);
 
                 cmd = fgets (cmdbuf, CMDBUFSIZ, stdin);
                 if (!cmd)
                         break;
-
-                printf ("processing command: '%s'\n", cmd);
+                len = strlen(cmd);
+                if (len > 0 && cmd[len - 1] == '\n') //strip trailing \n
+                        cmd[len - 1] = '\0';
                 ret = cli_cmd_process_line (state, cmd);
         }