Instead of using find, you can use bash directly, provided your search criteria are simple enough. E.g.,
for file in *; do
processFiles "$file"
done
will execute the function processFiles on all files and directories of the current directory (except the hidden ones) with argument the name of each file and directory. If you need to apply it recursively to all files and directories and subdirectories (except the hidden ones), use the globstar shell option:
#!/bin/bash
shopt -s globstar
shopt -s nullglob
updates=0
processFiles() {
((++updates))
}
for file in **; do
processFiles "$file"
done
echo "$updates"
If you just want files, and no directories, insert this in the for loop:
[[ -f "$file" ]] || continue
which will continue the loop if file is not a file (i.e., if it's something else, like a directory).
To match only files in a directory obtained by expanding the variable path, write your for loop thus:
for file in "$path"/*; do
(or "$path"/** if you're using globstar and want recursion).
If you need more complex search criteria, you can always use extglob option. If you need to also include the hidden files, use the dotglob option.
You'll find more info about bash in the reference manual, and in particular these sections:
One last note: If you really don't like this 100% bash solution and if you still want to do something along the script in your OP, then don't use bash variables, but use a (temporary) file instead to store the values you need to pass from one process to another. This is a cheap IPC method that works pretty well, but that is more difficult to implement safely.
updatesis modified in a child process. The parent process will never see its modifications. Now tell us what you're trying to achieve, maybe there's another solution that will be more efficient than the one you're trying.