diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-08-03 07:09:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-08-03 07:09:59 -0700 |
commit | 70a9ef01f022982241f80fe1eac19930aa597507 (patch) | |
tree | 67b38122140ef47de335564e6815770e3fa033be /linenoise/linenoise.c | |
parent | d4d626c256dd5147d308e609a9b6c341d8e0a02b (diff) | |
download | txr-70a9ef01f022982241f80fe1eac19930aa597507.tar.gz txr-70a9ef01f022982241f80fe1eac19930aa597507.tar.bz2 txr-70a9ef01f022982241f80fe1eac19930aa597507.zip |
listener: print prompts in plain mode if stdin is tty.
* linenoise/linenoise.c (linenoise): Force the printing of prompts
if the input file descriptor is a tty.
* txr.1: Documentation updated.
Diffstat (limited to 'linenoise/linenoise.c')
-rw-r--r-- | linenoise/linenoise.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 266542c1..256553d4 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -2533,12 +2533,13 @@ wchar_t *linenoise(lino_t *ls, const wchar_t *prompt) int count; int ifd = lino_os.fileno_fn(ls->tty_ifs); - if ( ls->noninteractive || !isatty(ifd)) { + if (ls->noninteractive || !isatty(ifd)) { wchar_t *ret = 0; size_t len = 0, i; const wchar_t *condensed_prompt = prompt + wcslen(prompt); + int show_prompt = ls->show_prompt || (ls->noninteractive && isatty(ifd)); - if (ls->show_prompt) { + if (show_prompt) { while (condensed_prompt > prompt && (*condensed_prompt == 0 || *condensed_prompt == ' ')) { @@ -2549,7 +2550,7 @@ wchar_t *linenoise(lino_t *ls, const wchar_t *prompt) for (;;) { size_t nlen; - if (ls->show_prompt) + if (show_prompt) lino_os.puts_fn(ls->tty_ofs, ret ? condensed_prompt : prompt); /* Not a tty: read from file / pipe. */ |