0

While writing a Makefile for a program (I wanted to check whether a particular directory exists or not, and if it does not exist, it performs some python code execution. Here is the code -

if [ -d "$(LOGOFOLDER)"]; then \
    echo "Directory already present." ; \
else \
    mkdir -p $(LOGOFOLDER) ;\
    $(PYTHON) ./generate_logos.py -d ;\
    echo ; \
    echo "Logo generated."; \
fi

However, every time I run the Makefile, the else part is executed (regardless of whether the file exists or not). Could anyone explain me where am I going wrong? Thanks.

  • Thanks a lot chepner! I searched a whole lot before posting this, strangely I didn't come across this. Need to improve my googling skills. :P – Rohit Kumar Jena Oct 13 '16 at 13:49
  • Yes, the problem was with the `[ ... ]` part of the code. After I introduced a space before the `]` , the code worked as desired. – Rohit Kumar Jena Oct 13 '16 at 16:44

0 Answers0