Tuesday, November 16, 2021

[SOLVED] Error: no source files when using command substitution

Issue

I have the following code:

all: ./source/Listener.java ./source/ServerThread.java ./source/TestClient.java 
    javac -d target $(find ./source/* | grep .java)

When I run Make, I get this output

javac -d target
error: no source files
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2

When I run the javac command in bash, it compiles fine. Furthermore, when I run the 'find' section, i get a list of files like I wanted. Additionally, the file paths in line 1 are all accurate.

Any tips?

(I have to use the find function because there are a lot of files in use, and it increases over time. I trimmed it down to 3, but the bug is still there anyway)


Solution

As RenaudPacalet said, I had to put an extra $ infront of the second line.



Answered By - user6697988