Reputation: 1869
I have a makefile in which I want to do checkout on a file if this file isn't already checkedout:
VAR=$(shell cleartool ls $(HOME)/all_files.tgz | grep CHECKEDOUT)
build:
@if ["$(VAR)" == ""]; then \
cleartool co -unres -nc $(HOME)/all_files.tgz;\
fi
@ tar czf $(HOME)/all_files.tgz $(OUT)/*.log
I get the following error if all_files.tgz is checked out:
/bin/sh: [/home/ge/prj/all_files.tgz@@/main/10/CHECKEDOUT from /main/10 Rule: CHECKEDOUT: not found
Upvotes: 1
Views: 1053
Reputation: 100816
When you use the brackets in the shell you MUST include whitespace around them. This is because [
is actually a separate command: if you use ["$(VAR)"
that expands to the string you quote above ([/home/ge/prj/all_files.tgz@@/main/10/CHECKEDOUT from /main/10
) and that is not a valid command name. Similarly for the final ]
: must have whitespace around it.
Use:
VAR=$(shell cleartool ls $(HOME)/all_files.tgz | grep CHECKEDOUT)
build:
@if [ "$(VAR)" == "" ]; then \
cleartool co -unres -nc $(HOME)/all_files.tgz;\
fi
@ tar czf $(HOME)/all_files.tgz $(OUT)/*.log
This is a kind of odd rule though. Since VAR is just a shell function, and you're using it in the shell, why even bother to use $(shell ...)
?
Upvotes: 2