c - GNU 读取线 : avoid prompt string in output if input is not interactive

标签 c terminal readline

我有一个带有提示的基于 readline 的应用程序,但我不希望它在输入非交互式时不显示。

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

这种情况下如何让提示不打印?

最佳答案

使用isatty(3)确定 stdin 和/或 stdout 是否连接到 tty。

关于c - GNU 读取线 : avoid prompt string in output if input is not interactive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2406826/

相关文章:

c - undefined symbol

java - 取消BufferedReader的readLine()

Java .split() 不工作

linux - 如果您失去 Internet 连接,在服务器上运行的命令会发生什么情况?

python - 使用 python 的 readline 处理带引号的行

c - 是否可以测试是否在 gnu Makefile 中声明了 C 定义?

c - 函数声明中的参数名称(无类型)

java - 长数据类型计算——为什么Java比C++快很多

python - 我如何打开不同的 linux 终端以在 python 中输出不同种类的调试信息?

regex - 如何在触发 "unterminated substitute pattern"错误的 bash 脚本中重新组织 sed 正则表达式中的嵌套引号?