]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
^$&%&*$&)% readline uses \n characters instead of letting the terminal wrap
authorTim Potter <tpot@samba.org>
Fri, 20 Jul 2001 07:46:39 +0000 (07:46 +0000)
committerTim Potter <tpot@samba.org>
Fri, 20 Jul 2001 07:46:39 +0000 (07:46 +0000)
the screen.  This mucks up expect something severe.  )-:

Don't use readline if the CLI_NO_READLINE environment variable is set.

source/lib/readline.c

index 75a38c68521f9c79e1763275824f79032b735f56..11d65a2b16dd497f032d16398969aa2dd3e11984 100644 (file)
 /****************************************************************************
 display the prompt and wait for input. Call callback() regularly
 ****************************************************************************/
-char *smb_readline(char *prompt, void (*callback)(void), 
-                  char **(completion_fn)(char *text, int start, int end))
+static char *smb_readline_replacement(char *prompt, void (*callback)(void), 
+                                      char **(completion_fn)(char *text, 
+                                                             int start, 
+                                                             int end))
 {
-       char *ret;
-#if HAVE_LIBREADLINE
-       if (completion_fn) {
-               rl_attempted_completion_function = completion_fn;
-       }
-
-       if (callback) rl_event_hook = (Function *)callback;
-       ret = readline(prompt);
-       if (ret && *ret) add_history(ret);
-       return ret;
-#else
        fd_set fds;
        extern FILE *dbf;
        static pstring line;
        struct timeval timeout;
        int fd = fileno(stdin);
+        char *ret;
 
        fprintf(dbf, "%s", prompt);
        fflush(dbf);
@@ -79,6 +71,35 @@ char *smb_readline(char *prompt, void (*callback)(void),
                }
                if (callback) callback();
        }
+}
+
+/****************************************************************************
+display the prompt and wait for input. Call callback() regularly
+****************************************************************************/
+char *smb_readline(char *prompt, void (*callback)(void), 
+                  char **(completion_fn)(char *text, int start, int end))
+{
+#if HAVE_LIBREADLINE
+       char *ret;
+
+        /* Aargh!  Readline does bizzare things with the terminal width
+           that mucks up expect(1).  Set CLI_NO_READLINE in the environment
+           to force readline not to be used. */
+
+        if (getenv("CLI_NO_READLINE"))
+                return smb_readline_replacement(prompt, callback, 
+                                                completion_fn);
+
+       if (completion_fn) {
+               rl_attempted_completion_function = completion_fn;
+       }
+
+       if (callback) rl_event_hook = (Function *)callback;
+       ret = readline(prompt);
+       if (ret && *ret) add_history(ret);
+       return ret;
+#else
+        return smb_readline_replacement(prompt, callback, completion_fn);
 #endif
 }