-   Linux - Newbie (
-   -   why always “syntax error near unexpected token 'fi'” (

dy20082250 10-08-2013 10:24 AM

why always “syntax error near unexpected token 'fi'”
I am a new to Linux .today I'm learning the makefile My script as following:
install: myapp
[tab]@if [ -d $(INSTDIR) ];\
[tab]cp myapp $(INSTDIR) &&\
[tab]chmod a+x $(INSTDIR)/myapp &&\
[tab]chmod og-w $(INSTDIR)/myapp &&\
[tab]echo "Installed in $(INSTDIR)";\
[tab]echo "Sorry,$(INSTDIR) does not exist" ;false ;\

when i run the "make -f makefile install"

/bin/sh:-c:line 8:syntax error near unexpected token 'fi'
/bin/sh:-c:line 8:'fi'
I have changed the makefile many times with many ways,but I can find out a solution.Please help me

Keith Hedger 10-08-2013 10:44 AM

A couple of things enclose code in "[code] [\code]" to make it easier to read ( without the quotes ).

add a space before each of the "\" like so

install: myapp
        @if [ -d $(INSTDIR) ]; \
        then \
        cp myapp $(INSTDIR) && \
        chmod a+x $(INSTDIR)/myapp && \
        chmod og-w $(INSTDIR)/myapp && \
        echo "Installed in $(INSTDIR)"; \
        else \
        echo "Sorry,$(INSTDIR) does not exist" ;false ; \

All times are GMT -5. The time now is 02:18 PM.