Consider libedit only in interactive mode (#1207)
This commit is contained in:
parent
72f097502f
commit
b10854677d
16
src/term.c
16
src/term.c
|
@ -1357,7 +1357,7 @@ void term_gotline(char *cmdstr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int terminal_mode(PROGRAMMER *pgm, struct avrpart *p) {
|
int terminal_mode_interactive(PROGRAMMER *pgm, struct avrpart *p) {
|
||||||
term_pgm = pgm; // For callback routine
|
term_pgm = pgm; // For callback routine
|
||||||
term_p = p;
|
term_p = p;
|
||||||
|
|
||||||
|
@ -1379,10 +1379,10 @@ int terminal_mode(PROGRAMMER *pgm, struct avrpart *p) {
|
||||||
return pgm->flush_cache(pgm, p);
|
return pgm->flush_cache(pgm, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int terminal_mode(PROGRAMMER *pgm, struct avrpart *p) {
|
int terminal_mode_noninteractive(PROGRAMMER *pgm, struct avrpart *p) {
|
||||||
char *cmdbuf;
|
char *cmdbuf;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
@ -1398,7 +1398,17 @@ int terminal_mode(PROGRAMMER *pgm, struct avrpart *p) {
|
||||||
return pgm->flush_cache(pgm, p);
|
return pgm->flush_cache(pgm, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int terminal_mode(PROGRAMMER *pgm, struct avrpart *p) {
|
||||||
|
#if defined(HAVE_LIBREADLINE)
|
||||||
|
// GNU libreadline can also work if input is a pipe.
|
||||||
|
// EditLine (NetBSD, MacOS) has issues with that, so only use it when
|
||||||
|
// running interactively.
|
||||||
|
// EditLine uses version 4.2 (0x0402).
|
||||||
|
if (isatty(fileno(stdin)) || (rl_readline_version >= 0x0500))
|
||||||
|
return terminal_mode_interactive(pgm, p);
|
||||||
#endif
|
#endif
|
||||||
|
return terminal_mode_noninteractive(pgm, p);
|
||||||
|
}
|
||||||
|
|
||||||
static void update_progress_tty(int percent, double etime, const char *hdr, int finish) {
|
static void update_progress_tty(int percent, double etime, const char *hdr, int finish) {
|
||||||
static char *header;
|
static char *header;
|
||||||
|
|
Loading…
Reference in New Issue