I have a script to fix permissions which is made up of blocks like:
FS_ROOT=/home/shared/Photos
FS_EXCLUDE=( \( -path */.webviews -o -path */.thumbnails \) -prune -o )
find $FS_ROOT ${FS_EXCLUDE[@]} -type d -not -perm 2770 -exec chmod 2770 "{}" \;
That fragment works as expected, but no matter what I try I cannot get the following to work:
FS_ROOT=/home/myhome
FS_EXCLUDE=( \( -path $FS_ROOT/dev -o -path $FS_ROOT/.\* \) -prune -o )
find $FS_ROOT ${FS_EXCLUDE[@]} -type d -not -perm 2770 -exec chmod 2770 {} \;
Without using an array to store the prune parameters it works on the command line and in a script, so there is nothing wrong with the find command itself. But when using the array it is matching hidden files.
I have tried different levels of escaping in case I needed to also escape the slash, but it made no difference.
Also I have tried using escaped single quotes, and running the script in sh and bash modes. The only difference with the latter was a single escaping slash in bash mode causes the wildcard to expand, the same as if no slash was used.
I want to use a variable to hold these parameters though as they are repeated on other find commands for file permissions and ownership, so any help on how to get this to work would be appreciated.
Michael.