22.2 The zsh/attr Module

The zsh/attr module is used for manipulating extended attributes. The -h option causes all commands to operate on symbolic links instead of their targets. The builtins in this module are:

zgetattr [ -h ] filename attribute [ parameter ]

Get the extended attribute attribute from the specified filename. If the optional argument parameter is given, the attribute is set on that parameter instead of being printed to stdout.

zsetattr [ -h ] filename attribute value

Set the extended attribute attribute on the specified filename to value.

zdelattr [ -h ] filename attribute

Remove the extended attribute attribute from the specified filename.

zlistattr [ -h ] filename [ parameter ]

List the extended attributes currently set on the specified filename. If the optional argument parameter is given, the list of attributes is set on that parameter instead of being printed to stdout.

zgetattr and zlistattr allocate memory dynamically. If the attribute or list of attributes grows between the allocation and the call to get them, they return 2. On all other errors, 1 is returned. This allows the calling function to check for this case and retry.