代码之家  ›  专栏  ›  技术社区  ›  Jaelebi

语法错误:文件结尾意外(应为“fi”)

  •  22
  • Jaelebi  · 技术社区  · 17 年前

    这是我试图运行的脚本

    read: 
            if [ -e testFile] ; then \ 
            cat testFile\ 
            fi
    

    错误是(当我键入:“make read”时)

    if [ -e testFile] ; then \
            cat testFile \
            fi
    /bin/sh: Syntax error: end of file unexpected (expecting "fi")
    make: *** [read] Error 2
    
    4 回复  |  直到 17 年前
        1
  •  28
  •   Julien Roncaglia    15 年前

    cat testFile 例如:

    read: 
        if [ -e testFile ] ; then  cat testFile ; fi
    

    或者:

    read:
        test -r testFile && cat testFile
    
        2
  •  9
  •   honkaboy    15 年前

    我也遇到了同样的问题。这应该可以做到:

    file:
        @if [ -e scripts/python.exe ] ; then \
        echo TRUE ; \
        fi
    
        3
  •  4
  •   Evidlo    8 年前

    自GNU Make 3.82以来,您可以添加 .ONESHELL: 在文件顶部,告诉make在单个shell中运行目标中的所有行。

    .ONESHELL:
    SHELL := /bin/bash
    
    foobar:
        if true
        then
            echo hello there
        fi
    

    documentation .

    预挂线条 @ .SILENT: 下方选项 .ONESHELL:

        4
  •  2
  •   HackNone    16 年前

    我也遇到了这个问题。