Skip to content

Commit 3588e00

Browse files
committed
Issue #2: Fix find error "paths must precede expression"
The asterisks were not escaped and in certain situations the shell expanded it to multiple paths, but the -path find parameter only accepts one value. Find encounter two values for the -path parameter and the error was triggered.
1 parent 3bb7845 commit 3588e00

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drupal_fix_permissions.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,20 @@ function fix_code_permission_helper() {
196196
case $simulate in
197197
0)
198198
# Real action.
199-
find "$1" \( -path "$1"/sites/*/$file_folder_name -prune \) -o \( -path "$1"/sites/*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print0 \) | xargs -r -0 -L4 chmod $3
199+
find "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print0 \) | xargs -r -0 -L4 chmod $3
200200
;;
201201

202202
1)
203203
# Simulate.
204-
num=$(find "$1" \( -path "$1"/sites/*/$file_folder_name -prune \) -o \( -path "$1"/sites/*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \) | wc -l)
204+
num=$(find "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \) | wc -l)
205205
printf "\n Code items with wrong permissions: $num"
206206
;;
207207

208208
2)
209209
# Simulate verbosely.
210210
printf "\n Code files and directories that would have their permissions fixed: "
211211
# Use a variable to indent output.
212-
items=$(find "$1" \( -path "$1"/sites/*/$file_folder_name -prune \) -o \( -path "$1"/sites/*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \))
212+
items=$(find "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \))
213213
items=${items:-None}
214214
printf "\n ${items//$'\n'/$'\n' }\n"
215215
;;
@@ -481,3 +481,4 @@ echo "$additional_files_paths"| while read path; do
481481
done
482482

483483
printf "\n\nPermissions and ownership fixed!\n"
484+

0 commit comments

Comments
 (0)