web-dev-qa-db-ja.com

tputedが空です

tput edの出力は空であり、その理由がわかりません。他の機能は正常に機能します。また、edinfocmp出力から欠落していないので、tputは一致するはずですよね?

$ printf '%q' "$(tput ed)"
''
$ printf '%q' "$(tput home)"
$'\033'\[H

Mac OS10.14.6とiTerm2でzshを使用しています。 TERM = xterm-256color。

1
cambunctious

ドキュメント(主にterminfo)をさらに調べて精査しているので、capnameがすべてのterminfoでサポートされているわけではないため、古いtermcapコードにフォールバックする必要があることがようやくわかりました。機能。

ed=$(tput ed || tput cd)
1
cambunctious

Appleは、(デフォルトのterminfoに加えて)termcapをサポートするncursesを構成しました。

  • config.status 構成オプションを示すファイル。
  • infocmpは _ nc_read_file_entry を呼び出してデータを取得します。
  • tputは setupterm を呼び出し、_nc_read_entryに移動し、_nc_read_tic_entry、これは_nc_read_file_entryを呼び出します
  • _nc_read_tic_entryに問題がある場合、_nc_read_entryはtermcapにフォールバックしますサポート( read_entry.c を参照)。

これは10年前のコードであるため、_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

PATHをコメント化/コメント解除して2つから選択します)、2番目のスクリプト/tmp/test-tputを呼び出して値を表示します:

#!/bin/bash
tput "$1" >/dev/null 2>/dev/null || exit
echo -n "CAP:$1 "
tput "$1" 2>/dev/null
echo

Ncurses 5.7の動作は、 1999 で導入されたバグでした。

    + modify tput to accept termcap names as an alternative to terminfo
      names (patch by Jeffrey C Honig).

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).

Appleの ncurses 5.7 は、その修正よりも約1年古いです。

3
Thomas Dickey