-1

This question already has an answer here:

I have this:

find_files(){
  (cd "$project_root/$root_dir" && find . -type f)
}

for f in find_files; do
   ::
done;

but my IDE warns:

enter image description here

I think putting backticks around the bash function would work:

enter image description here

but I am not really sure why the back-ticks work?

marked as duplicate by Jeff Schaller bash Sep 6 at 0:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • They might get rid of the IDE warning, but that code will break with any filename containing IFS or wildcards. – Jeff Schaller Sep 5 at 23:35
2

You want to run your function then act on its output, that's command substitution, so it's either this:

for f in `find_files`   

or this:

for f in $(find_files)  

These 2 syntax are equivalent, but the first one is old-style, the latter one is new . Check bash documentation on command substitution.

Further more it's probably not a good idea to loop through the output of your find command, you may want to check out Bash Pitfalls.

Not the answer you're looking for? Browse other questions tagged or ask your own question.