Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to edit extended attributes of directories that are symbolic links.

xattr that comes on OSX 10.5 unfortunately writes to the link target instead of the link itself.

I discovered a different version that supports a "-s" option to suppress following symbolic links. I checked it out of the repository, but there is no installer file that I can make out and I think I need one:

Then I found another version and also checked it out, and was finally able to install it after installing Xcode:

However when I run this version I don't appear to get the magic "-s" option to suppress following symbolic links. In fact this version didn't appear to have any other options that the original xattr had.

Does anyone have a version of xattr running on OSX 10.5 that will support not following symbolic links, or any other app that will allow me to write extended attributes and not follow symbolic links ?

share|improve this question
up vote 1 down vote accepted

The variation at has the -P option that suppresses the usual behavior of following symbolic links (i.e. passes the XATTR_NOFOLLOW option to listxattr(2), etc.). The included documentation indicates that this “operate on the symlink, not the target” mode is the default (it used to default to operating on the target, but the code was recently updated to match the documentation).

The options and modes of operation are different from the usual xattr(1), so you will probably have to adapt any scripts that you already have in place.

Since you said you have already installed the Developer Tools (i.e. Xcode), a simple make should build the program. I compiled and lightly tested it on a machine running Mac OS X 10.6.7 (I have also previously used it on a 10.4 machine, so it should work fine on 10.5).

Note about “directories that are symbolic links”: A directory entry can either be a directory or a symbolic link (or a plain file, etc.), but not both. It is not accurate to say either “a directory that is a symbolic link” or “a symbolic link that is a directory”. Properly, it just “a symbolic link that ultimately2 points to a directory”.

1 You can use the Downloads button on the right side of the GitHub page to download a .tar.gz or .zip if you do not have Git installed.

2 “Ultimately” because symbolic links can point to other symbolic links. They can even point to a non-existent pathname (creating a “dangling” symbolic link).

share|improve this answer
many thanks for yet another xattr :) I downloded the tar, extracted it, then "$ make" from the folder containing the Makefile. I then got the following: "gcc -o xattr xattr.c -std=c99 -O2 ld: can't open output file for writing: xattr collect2: ld returned 1 exit status make: *** [xattr] Error 1" I don't know how to make this makefile work :( Also thank you for the lesson in the definition of a symbolic link :) – timoto May 7 '11 at 15:25
@timoto: That looks like you do not have write access to the directory you are in. Did you perhaps extract it as root or another user? There should no need for sudo just to unpack this tar file and build the program. – Chris Johnsen May 7 '11 at 20:17
DOH! My hat off to you sir. Permissions mismatch indeed. Make as the user that extracted the tar works. I can now see a lovely "-P" in the xattr help and presumably "-s" (set) is write. Thank you Chris. – timoto May 7 '11 at 20:53
@timoto: Yes, -s is for “set”. I neglected to mention the documentation. The documentation’s “source” is xattr.pod. It is plain text, but the Pod markup might be a bit of a pain to “read around”. You can use man ./xattr.1 to read the documentation as a manpage. – Chris Johnsen May 8 '11 at 7:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .