diff options
author | Tim Potter <tpot@samba.org> | 2001-07-20 07:46:39 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-07-20 07:46:39 +0000 |
commit | f0b7593ef54f8f093018ee2a8325e6f4422a4bbd (patch) | |
tree | 2b1610794ca261afa2f5a409768c51b0f787562e | |
parent | e0ebbc9ae3277a5a389eef021f32509a017cbd4d (diff) | |
download | samba-f0b7593ef54f8f093018ee2a8325e6f4422a4bbd.tar.gz samba-f0b7593ef54f8f093018ee2a8325e6f4422a4bbd.tar.xz samba-f0b7593ef54f8f093018ee2a8325e6f4422a4bbd.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.
-rw-r--r-- | source/lib/readline.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/source/lib/readline.c b/source/lib/readline.c index 75a38c68521..11d65a2b16d 100644 --- a/source/lib/readline.c +++ b/source/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 } |