This answer is an addition to Gordon Davisson's answer for inherited
attributes.
Tested on: Mac OS X 11.12.1, bash 3.2.57
It looks like chmod -E
doesn't support the inherited
option. I found a workaround.
- It is important to understand that
allow
\ deny
entries can be local
(default) and inherited
.
- flag
-a
adds local
entries, -ai
adds inherited
entries.
chown $(stat -f%u:%g "$srcdir") "$dstdir" # Copy owner and group
chmod $(stat -f%Mp%Lp "$srcdir") "$dstdir" # Copy the mode bits
chmod -N "$dstdir" # Removes all ACL entries. It can be important because '+a' adds entries, not replaces
chmod +ai "$(ls -lde "$srcdir" | tail +2 | sed -e 's/^ [0-9]*: //' -e 's/ inherited / /'; echo)" "$dstdir" # Adding inherited entries