Search code examples
xcodebashmacosxattr

Recursive xattr fails horribly


I've been trying to figure out a way to recursively remove all of the xattr for some files, however, none of the previous methods seem to work anymore; there might be a newly introduced bug too?

$ xattr -rc .
option -r not recognized

$ xattr -c .
option -c not recognized

..and now the grand finale!

$ 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

Oh look it found an xattr amongst the muck... it would be interesting to know how, what or who destroyed the xattr tool so badly. I just need to recursively remove extended attributes, really!


Solution

  • You appear to have a nonstandard xattr command installed in /usr/local/bin/xattr (the standard one that ships with macOS is /usr/bin/xattr). Those are Python errors, so maybe it's this one? Anyway, it doesn't use the same syntax as the standard one, so having it installed is going to cause confusion; I'd recommend either removing it or renaming it to something distinct; otherwise it's likely to break any scripts (yours or system) that try to use xattr.