Рекурсивный XATTR ужасно терпит неудачу

Я пытался найти способ рекурсивно удалить все xattr однако для некоторых файлов ни один из предыдущих методов больше не работает; Там может быть недавно введенная ошибка тоже?

$ xattr -rc .
option -r not recognized

$ xattr -c .
option -c not recognized

..и теперь великий финал!

$ find . -exec xattr -l {} \;
com.apple.FinderInfo:
Traceback (most recent call last):
  File "/usr/local/bin/xattr", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/xattr/tool.py", line 200, in main
    print(_dump(attr_value))
  File "/Library/Python/2.7/site-packages/xattr/tool.py", line 77, in _dump
    printable = s.translate(_FILTER)
TypeError: character mapping must return integer, None or unicode

О, посмотри, что нашел xattr среди гадости... было бы интересно узнать, как, что или кто уничтожил xattr инструмент так плохо. Мне просто нужно рекурсивно удалить расширенные атрибуты, правда!

1 ответ

Решение

У тебя нестандартный вид xattr Команда, установленная в /usr/local/bin/xattr (стандартная, которая поставляется с macOS - /usr/bin/xattr). Это ошибки Python, так что, может быть, это одна? В любом случае, он не использует тот же синтаксис, что и стандартный, поэтому его установка может привести к путанице; Я бы порекомендовал либо удалить его, либо переименовать в нечто отличное; в противном случае он может сломать любые скрипты (ваши или системные), которые пытаются использовать xattr,

Это случилось и со мной. и я считаю, что это из-за моего$PATH

/usr/local/bin:/usr/bin

Мой user local bin приходит перед моим system usr/bin.

Благодаря этим сообщениям я разобрался в проблеме.

xattr был установлен в двух местах.

Покажите, является ли цель встроенной, функцией, псевдонимом или внешним исполняемым файлом. (Источник) /

type -a xattr
# xattr is /usr/local/bin/xattr
# xattr is /usr/bin/xattr

и они точно разные.

/usr/local/bin/xattr -h
usage: xattr [-slz] file [file ...]
       xattr -p [-slz] attr_name file [file ...]
       xattr -w [-sz] attr_name attr_value file [file ...]
       xattr -d [-s] attr_name file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to attr_value.
The fourth form (-d) deletes the xattr attr_name.

options:
  -h: print this help
  -s: act on symbolic links themselves rather than their targets
  -l: print long format (attr_name: attr_value)
  -z: compress or decompress (if compressed) attribute value in zip format

VS.

/usr/bin/xattr -h
usage: xattr [-l] [-r] [-s] [-v] [-x] file [file ...]
       xattr -p [-l] [-r] [-s] [-v] [-x] attr_name file [file ...]
       xattr -w [-r] [-s] [-x] attr_name attr_value file [file ...]
       xattr -d [-r] [-s] attr_name file [file ...]
       xattr -c [-r] [-s] file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to the string attr_value.
The fourth form (-d) deletes the xattr attr_name.
The fifth form (-c) deletes (clears) all xattrs.

options:
  -h: print this help
  -l: print long format (attr_name: attr_value and hex output has offsets and
      ascii representation)
  -r: act recursively
  -s: act on the symbolic link itself rather than what the link points to
  -v: also print filename (automatic with -r and with multiple files)
  -x: attr_value is represented as a hex string for input and output

Итак, если вы по какой-то причине хотите сохранить и то, и другое, вы можете просто вызвать их явно следующим образом:

/usr/bin/xattr -lr ~

/usr/local/bin/xattr -l ~
Другие вопросы по тегам