Отсутствие маркера % p
является причудой ncurses: компилятор terminfo ( tic ) распознает либо terminfo (который использует % p1
до mark parameters) или termcap (который полагается на соглашение для параметров). Это было бы допустимое выражение termcap . Поскольку tic знает, как обрабатывать выражение termcap, показанная строка является «достаточно близкой», чтобы не было необходимости переводить ее дальше.
Вы можете увидеть, что делает ncurses, используя tput
, например,
tput u6 40 50
дает (обратите внимание на изменение параметров)
^[[51;41R
Если бы выражение было задано как
u6=\E[%i%p2%d;%p1%dR
, результат был бы тот же.
Возможности u6-u9 являются ранним расширением , задокументированным в базе данных терминала ncurses :
# INTERPRETATION OF USER CAPABILITIES
#
# The System V Release 4 and XPG4 terminfo format defines ten string
# capabilities for use by applications, .... In this file, we use
# certain of these capabilities to describe functions which are not covered
# by terminfo. The mapping is as follows:
#
# u9 terminal enquire string (equiv. to ANSI/ECMA-48 DA)
# u8 terminal answerback description
# u7 cursor position request (equiv. to VT100/ANSI/ECMA-48 DSR 6)
# u6 cursor position report (equiv. to ANSI/ECMA-48 CPR)
#
# The terminal enquire string should elicit an answerback response
# from the terminal. Common values for will be ^E (on older ASCII
# terminals) or \E[c (on newer VT100/ANSI/ECMA-48-compatible terminals).
#
# The cursor position request () string should elicit a cursor position
# report. A typical value (for VT100 terminals) is \E[6n.
#
# The terminal answerback description (u8) must consist of an expected
# answerback string. The string may contain the following scanf(3)-like
# escapes:
#
# %c Accept any character
# %[...] Accept any number of characters in the given set
#
# The cursor position report () string must contain two scanf(3)-style
# %d format elements. The first of these must correspond to the Y coordinate
# and the second to the %d. If the string contains the sequence %i, it is
# taken as an instruction to decrement each value after reading it (this is
# the inverse sense from the cup string). The typical CPR value is
# \E[%i%d;%dR (on VT100/ANSI/ECMA-48-compatible terminals).
#
# These capabilities are used by tack(1m), the terminfo action checker
# (distributed with ncurses 5.0).
Проверка последнего комментария, tack упражнения u8
и u9
, но ничего не делает с u6
и u7
.
Расширение было добавлено в начале 1995 г. :
# 9.3.4 (Wed Feb 22 19:27:34 EST 1995):
# * Added correct acsc/smacs/rmacs strings for vt100 and xterm.
# * Added u6/u7/u8/u9 capabilities.
# * Added PCVT entry.
и хотя оно включено в несколько записей для полноты (немного: в 18 699 строках встречается 16 ] terminfo.src
), известных пользователей этой функции нет. Фактически, есть одно место в ncurses, где он мог быть написан для его использования (некоторый отладочный код ifdef в файле tty_update.c
), но для этого используется жестко - закодированные escape-последовательности (помеченные как «ANSI-совместимые»).
Причиной отсутствия пользователей может быть следующее:
В ECMA-48 , это (u7) DSR (отчет о состоянии устройства) и (u6) CPR (отчет об активном положении).
За исключением того факта, что csh
не любит восклицательный знак без экранирования, в командной строке ваша команда выглядит нормально и ее нельзя улучшить
Если вы хотите запустить его из /bin/sh
скрипта:
#!/bin/sh
# the users to avoid
set -- user1 user2 user3 user4
# create a list of
# -o -user "username" -o -user "username" etc.
for user do
set -- "$@" -o -user "$user"
shift
done
shift # remove that first "-o"
# use the created array in the call to find
find. -maxdepth 1 -type d -name '*_pattern_*' ! '(' "$@" ')'
В качестве альтернативы, чтобы создать такой же ! -user "username"
список, который вы используете:
#!/bin/sh
# the users to avoid
set -- user1 user2 user3 user4
# create a list of
# ! -user "username" ! -user "username" etc.
for user do
set -- "$@" ! -user "$user"
shift
done
# use the created array in the call to find
find. -maxdepth 1 -type d -name '*_pattern_*' "$@"
В cshell вы можете создать команду find
для выполнения задания следующим образом:
#!/bin/tcsh -f
# persona non grata
set png = ( \
user1 \
user2 \
user3 \
user4 \
)
# build dynamically a portion of the `find` command
set cmd = ( `printf '! -user %s\n' $png:q` )
# now fire the generated find command
find. -maxdepth 1 -type d -name '*_pattern_*' $cmd:q