bash .profile:第 31 行:语法错误:文件意外结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3869636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 22:44:39  来源:igfitidea点击:

.profile: line 31: syntax error: unexpected end of file

bash.profile

提问by name

I'm bad at bash programming. Where is the error? Here is my .profile file:

我不擅长 bash 编程。错误在哪里?这是我的 .profile 文件:

# WARNING: For help understanding this file, and before you try
# to change any of it, type "man .profile" and read carefully.
#

#
# Set command search rules
#
if [ -x /bin/showpath ] ; then ?
????export PATH; PATH=`/bin/showpath $HOME/bin /u/cs350/sys161/bin /software/gnu/bin standard`
    export PATH; PATH=`/bin/showpath usedby=user standard $HOME/bin`
#
# Find out what kind of terminal we are using
#
    eval `setterm  sytek:kd404  default:vc404`
#
# Set terminal-type dependent options (e.g. sysline or prompt string)
#
    #HOMEHOST="<hostname>"
    #HOMEUSER="<userid>"
    #export HOMEHOST HOMEUSER
    PS1="$ "
#
# Now do the usual signing on things
#
    export MAIL; MAIL=${MAIL-"/usr/spool/mail/$USER"}

if [ -r /software/.admin/bins/bin/read_system_news ] ; then /software/.admin/bins/bin/read_system_news ; fi

EOF

回答by Ignacio Vazquez-Abrams

Your first ifis missing a fi.

您的第一个if缺少fi.

回答by codaddict

You are missing a fiat the end of file add it.

fi在文件末尾缺少一个添加它。

Also get rid of EOF. The EOFin your case is treated as a command.

也摆脱EOF。在EOF你的情况被视为命令。

Sometimes running your script using different shells gives you a clue about the error.

有时,使用不同的 shell 运行脚本会给您提供有关错误的线索。

When we run your program using:

当我们使用以下命令运行您的程序时:

  • shit says Syntax error: end of file unexpected (expecting "fi")
  • cshit says if: Expression Syntax.
  • sh它说 Syntax error: end of file unexpected (expecting "fi")
  • csh它说 if: Expression Syntax.