cam*_*ous 4 tput terminfo macos
的输出tput ed
为空,我不知道为什么。其他功能工作正常。输出中也ed
没有丢失,infocmp
所以 tput 应该匹配,对吗?
$ printf '%q' "$(tput ed)"
''
Run Code Online (Sandbox Code Playgroud)
$ printf '%q' "$(tput home)"
$'\033'\[H
Run Code Online (Sandbox Code Playgroud)
我在 Mac OS 10.14.6 和 iTerm2 上使用 zsh。术语=xterm-256color。
经过更多的谷歌搜索和搜索文档(主要是 terminfo),我终于发现我需要回退到旧的termcap代码,因为所有 terminfo 功能都不支持capname 。
ed=$(tput ed || tput cd)
Run Code Online (Sandbox Code Playgroud)
Apple 为 ncurses 配置了 termcap 支持(除了默认的 terminfo):
_nc_read_entry
,调用_nc_read_tic_entry
,调用_nc_read_file_entry
_nc_read_tic_entry
,则_nc_read_entry
回退到 termcap 支持(请参阅read_entry.c
)。由于那是十年前的代码,_nc_read_tic_entry 中可能存在的问题可能已经修复了一段时间。
例如,我安装了 MacPorts,并且可以正常工作,而 Apple 的版本则没有。这是我用来调查问题的顶级脚本:
#!/bin/sh
unset TERMINFO
unset TERMINFO_DIRS
export TERM=xterm-256color
#export PATH=/usr/bin:$PATH
echo TERMCAP
infocmp -CrTt1 | grep -E ':..=.*:' | sed -e 's/^ ://' -e 's/=.*//' | xargs -n 1 /tmp/test-tput
echo TERMINFO
infocmp -1 | grep -E '^ .*=.*,' | sed -e 's/^ //' -e 's/=.*//' | xargs -n 1 /tmp/test-tput
Run Code Online (Sandbox Code Playgroud)
(注释/取消注释PATH
以在两者之间进行选择),然后调用第二个脚本/tmp/test-tput
来显示值:
#!/bin/bash
tput "$1" >/dev/null 2>/dev/null || exit
echo -n "CAP:$1 "
tput "$1" 2>/dev/null
echo
Run Code Online (Sandbox Code Playgroud)
ncurses 5.7 中的行为是1999 年引入的一个错误
+ modify tput to accept termcap names as an alternative to terminfo
names (patch by Jeffrey C Honig).
Run Code Online (Sandbox Code Playgroud)
并于2009 年修正:
+ change order of lookup in progs/tput.c, looking for terminfo data
first. This fixes a confusion between termcap "sg" and terminfo
"sgr" or "sgr0", originally from 990123 changes, but exposed by
20091114 fixes for hashing. With this change, only "dl" and "ed" are
ambiguous (Mandriva #56272).
Run Code Online (Sandbox Code Playgroud)
Apple 的ncurses 5.7比该修复程序早了大约一年。