I am trying to write a csh script which will execute a makefile in child directories when present. So far I have this:
find -maxdepth 2 -name 'Makefile' -print -execdir make \;
The issue I'm facing is that I get the following error when I try to run it:
find: The current directory is included in the PATH environment variable, which is insecure in combination with the -execdir action of find. Please remove the current directory from your $PATH (that is, remove "." or leading or trailing colons)
I cannot reasonably change the $PATH variable in this case. Any ideas on a workaround.
Many thanks and happy coding
The -execdir
flag is a feature of GNU find, and the way it's implemented is to throw that error and refuse to proceed if the situation it describes is detected. There's no option in find
to avoid that error. So, you can either fix PATH
(you can do that just for the find
command itself:
PATH=<fixed-path> find -maxdepth 2 -name 'Makefile' -print -execdir make \;
) or else don't use -execdir
as described by Basile.
Err... actually that's POSIX sh syntax. Does csh
support that? I haven't used csh
in so long that I can't remember, and honestly it's such a bad shell that I can't be bothered to go look :-p :-)