So I am trying to run a jq command inside a makefile to link some dependencies, and I do not understand what the line inside the do-done does. If using only echo "$$dep" I understand what's going on, but when using the full line of code ([ -f "$$dep/package.json" ] && echo "$$dep";) I seem to be lost. Does anyone have any idea? Thanks.
jq -r '.dependencies,.devDependencies|keys[]' $< | while read -r dep; do \
[ -f "$$dep/package.json" ] && echo "$$dep"; \
done | (piping forward)
Since this is in a makefile
, there are two things that need to be understood. First, to understand the "$$" variable ( $$dep
), see this stackoverflow question:
Second, to understand the ... in do ... done
, remember that this is essentially equivalent to a shell conditional of the form:
if [ -f _ ] ; then echo _ ; fi
For details about the test, see eg http://wiki.bash-hackers.org/commands/classictest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.