linux终端输出冗余内容

linux terminal output redundant content

我的Linux是Arch,我的配置如下:

Kernel: 5.13.13-arch1-1
Packages: 490 (pacman)
Shell: zsh 5.8
WM: dwm
Terminal: st
Terminal Font: Source Code Pro

当我使用C输出语句时,例如printfputchar('A');,如果我不在末尾添加\r或\n,我会得到一个额外的'%'字符在终端上。

$ ./a.out
A%
$

这个问题困扰了我很久,搞得我都不知道问题出在哪里,dwm?与嘘?用 zhs?

这是 zsh 的一个功能,用于显示程序何时结束而没有最后的换行符,并将 zsh 的命令提示符与程序输出区分开来。

You can disable it with the zsh command PROMPT_EOL_MARK=''. 你也可以设置成其他的,比如PROMPT_EOL_MARK=' -- The program did not end with a newline.'.