7

Here is my make target:

copy_python:
    if test -d $(VIRTUAL_ENV)/lib; then \
        cp -a $(VIRTUAL_ENV)/lib/python2.7/site-packages/. ./package/tmp/; \
    fi
    if test -d $(VIRTUAL_ENV)/lib64; then \
        cp -a $(VIRTUAL_ENV)/lib64/python2.7/site-packages/. ./package/tmp/; \ 
    fi

Here is the error:

/bin/sh: 2: Syntax error: end of file unexpected (expecting "fi")
Makefile:28: recipe for target 'copy_python' failed
make: *** [copy_python] Error 2

Why does this error occur?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578

1 Answers1

11

You have an extra space after the ending backslash, at the end of the second cp command. For this reason, \ no longer acts as a line continuation and the fi on the next line is not passed to sh

xhienne
  • 5,738
  • 1
  • 15
  • 34
  • 2
    Yep, it's a space at the end of the line with the second `cp` command. I can tell because it's actually preserved in the pasted code snippet! This is why it's best to copy & paste code in questions, rather than retyping. – Gordon Davisson Sep 29 '17 at 01:23
  • Thank you @GordonDavisson, I have rephrased my answer accordingly. – xhienne Sep 29 '17 at 07:29