summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-07-20 07:46:39 +0000
committerTim Potter <tpot@samba.org>2001-07-20 07:46:39 +0000
commitf905c74d9ab24a51d036853a8c609d8da3e5c91f (patch)
treeda53a33862c3dc9b1f59d962a74e01a7c7e77ee6 /source3
parent57933a9c6f1a914b69dd38e0346ac17d47f87d45 (diff)
downloadsamba-f905c74d9ab24a51d036853a8c609d8da3e5c91f.tar.gz
samba-f905c74d9ab24a51d036853a8c609d8da3e5c91f.tar.bz2
samba-f905c74d9ab24a51d036853a8c609d8da3e5c91f.zip
^$&%&*$&)% readline uses \n characters instead of letting the terminal wrap
the screen. This mucks up expect something severe. )-: Don't use readline if the CLI_NO_READLINE environment variable is set. (This used to be commit f0b7593ef54f8f093018ee2a8325e6f4422a4bbd)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/readline.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/source3/lib/readline.c b/source3/lib/readline.c
index 75a38c6852..11d65a2b16 100644
--- a/source3/lib/readline.c
+++ b/source3/lib/readline.c
@@ -43,25 +43,17 @@
/****************************************************************************
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
}