GNU readline: avoid prompt string in output if input is not interactive

核能气质少年 提交于 2019-12-13 14:40:08

问题


I have a readline-based application with a prompt, however I'd like it to not show when the input is not interactive.

$ ./readline-app < command-list > result
$ cat result
prompt> Output line 1
prompt> Output line 2
prompt>
$

How can I make the prompt to not print in this case?


回答1:


Use isatty(3) to determine whether stdin and/or stdout are connected to a tty.



来源:https://stackoverflow.com/questions/2406826/gnu-readline-avoid-prompt-string-in-output-if-input-is-not-interactive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!