Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 为什么我会得到;意外的文件结尾“;?_Bash - Fatal编程技术网

Bash 为什么我会得到;意外的文件结尾“;?

Bash 为什么我会得到;意外的文件结尾“;?,bash,Bash,我正在学习解析参数的教程。当我运行带有或不带参数的脚本时,我得到“第45行:语法错误:文件意外结束”。 这是脚本中最后一行之后的一行。我只是没有看到这个错误(bash脚本编写的新手…) #/bin/bash #解释可以传入的参数 参数用法(){ cat这是因为您在此处缩进了EOF argumentUsage(){ ... OPTIONS: -h Show this message -s Source location -d

我正在学习解析参数的教程。当我运行带有或不带参数的脚本时,我得到“第45行:语法错误:文件意外结束”。 这是脚本中最后一行之后的一行。我只是没有看到这个错误(bash脚本编写的新手…)

#/bin/bash
#解释可以传入的参数
参数用法(){

cat这是因为您在此处缩进了
EOF

argumentUsage(){
     ...
     OPTIONS:
       -h    Show this message
       -s    Source location
       -d    Destination location
     EOF
}

由于缩进,bash没有“看到”终止的
EOF
,因此实际上您的here文档是未终止的,这会导致“意外的文件结尾”。

这是因为您在此处缩进了
EOF

argumentUsage(){
     ...
     OPTIONS:
       -h    Show this message
       -s    Source location
       -d    Destination location
     EOF
}

由于缩进,bash没有“看到”终止的
EOF
,因此实际上您的here文档是未终止的,这会导致“文件意外结束”.

@anishsane,这个注释不应该发布在问题上吗?我只是在函数定义中显示相关的点。@anishsane,这个注释不应该发布在问题上吗?我只是在函数定义中显示相关的点。另外,调用函数时,不应该指定
()
。更改
用法()
到开关盒条目中的
argumentUsage
。此外,对于调用函数,不应指定
()
。将开关盒条目中的
argumentUsage()
更改为
argumentUsage