简体   繁体   English

.bashrc 语法错误:文件意外结束

[英].bashrc syntax error: unexpected end of file

I am getting an unexpected end of file error.我收到意外的文件结束错误。 I am not really sure how to fix it.我不太确定如何修复它。

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions

export PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'

export LS_COLORS='di=35;1'


alias la='ls -lah'
alias cdu='cd /home/hzhang/primary'

#module load gnu-compilers/4.7.0
#module load mvapich3/gnu/1.7

.ls /opt/intel/Compiler/11.1/072/bin/ifortvars.sh intel64

#PATH=$PATH:/home/hzhang/primary/over2.2e/bin_dp:/home/hzhang/primary/foiltest
PATH=$PATH:/opt/overflow/intel/serial/bin_dp/:/home/hzhang/primary/chimera2.1/bin_dp/:/u/primary/hzhang/pegasus/bin_dp
export PATH

ulimit -s unlimited 

I had the same error due to missing "fi" line.由于缺少“fi”行,我遇到了同样的错误。 Make sure to omit syntax errors.确保省略语法错误。 The original .bashrc is located in /etc/skel/.原始 .bashrc 位于 /etc/skel/。 So just run the following command:所以只需运行以下命令:

cp /etc/skel/.bashrc ~ cp /etc/skel/.bashrc ~

I was facing a similar problem.我面临着类似的问题。 Using the bash that comes with Windows 10, somehow the line endings had been changed to windows line endings (CRLF).使用 Windows 10 附带的 bash,不知何故,行尾已更改为 Windows 行尾 (CRLF)。 Changing the file back to use unix line endings solved the issue.将文件改回使用 unix 行结尾解决了这个问题。

Convert eh line endings to unix endings and see if that solves the issue.将 eh 行结尾转换为 unix 结尾,看看是否能解决问题。 If editing in Vim, enter the command :set fileformat=unix and save the file.如果在 Vim 中编辑,输入命令:set fileformat=unix并保存文件。 Several other editors have the ability to convert line endings, such as Notepad++ or Atom其他几个编辑器具有转换行尾的能力,例如Notepad++Atom

Such syntax errors are really simple to find.这样的语法错误很容易找到。 At first glance the file looks okay, so I'd suggest you comment out every single line (with # ) and see if the error still manifests.乍一看,该文件看起来没问题,所以我建议您注释掉每一行(使用# ),看看错误是否仍然存在。

Then just do binary search, that is, comment in the first half of the file.然后只做二分查找,即在文件的前半部分注释。 If that works continue with the third quarter (otherwise with the first quarter).如果第三季度继续有效(否则第一季度)。 And so forth.等等。

I had a similar problem, it turned out to be a missing "}" at the end of a function.我有一个类似的问题,结果是函数末尾缺少“}”。 I made a backup of the faulty one (in order to have an idea of what my setup was) and then copied the original fine (cp /etc/skel/.bashrc ~) and added the lines again.我备份了有故障的那个(以便了解我的设置是什么),然后复制原始的罚款(cp /etc/skel/.bashrc ~)并再次添加这些行。

I had the same issue because i made some changes in my .bashcr file and messed up the terminal.我遇到了同样的问题,因为我对 .bashcr 文件进行了一些更改并弄乱了终端。 Follow command fixed my issue:按照命令解决了我的问题:

ecp /etc/skel/.bashrc ~

This .bashrc shall have been edited from windows.这个 .bashrc 应该是从 windows 编辑的。 fromdos .bashrcé to correct this file in order to source it. fromdos .bashrcé 更正此文件以获取它。

Just open the file from terminal by gedit .bashrc The document will open ,go to the bottom and see if fi is missing there,if it is not there add it.Just put "fi" at the left margin at the last and close all the commands with "fi".只需通过gedit .bashrc文件将打开,转到底部,看看那里是否缺少fi ,如果没有,请添加它。只需将“fi”放在最后的左边距并关闭所有带有“fi”的命令。 see here看这里

I Swear not to use zsh again.我发誓不再使用 zsh。 it messed up my system trying to play around with it.它弄乱了我的系统试图玩弄它。

ecp /etc/skel/.bashrc ~

fixed my issue too也解决了我的问题

. . . . . . if !如果 ! shopt -oq posix; shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ];那么如果 [ -f /usr/share/bash-completion/bash_completion ]; then .然后 。 /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then .然后 。 /etc/bash_completion fi Fi In the first line of my terminal i got There is error at the end of the /.bashrc file but when i change Fi to fi it works fine like /etc/bash_completion fi Fi在我的终端的第一行我得到了 /.bashrc 文件末尾有错误但是当我将Fi更改为fi时它工作得很好

. . . . . . . . if !如果 ! shopt -oq posix; shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ];那么如果 [ -f /usr/share/bash-completion/bash_completion ]; then .然后 。 /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then .然后 。 /etc/bash_completion fi fi /etc/bash_completion fi fi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM